Mercurial > geeqie
annotate src/format_olympus.c @ 111:3a69a7a3f461
Wed Nov 15 02:05:27 2006 John Ellis <johne@verizon.net>
* view_file_icon.c: Fix odd crash when removing files, it seems the
high priority idle sync is no longer called before the treeview tries
to redraw itself, so fix the cleanup of removed pointers so that they
are always valid or NULL (I wonder if the priorities used by
GtkTreeView have changed in newer versions of GTK?).
* view_file_list.c: Fix progress bar warning when files are removed
before thumbnail generation is finished.
author | gqview |
---|---|
date | Wed, 15 Nov 2006 07:19:16 +0000 |
parents | 847e4bc6b54c |
children | 71e1ebee420e |
rev | line source |
---|---|
57 | 1 /* |
2 * GQView | |
3 * (C) 2005 John Ellis | |
4 * | |
5 * This software is released under the GNU General Public License (GNU GPL). | |
6 * Please read the included file COPYING for more information. | |
7 * This software comes with no warranty of any kind, use at your own risk! | |
8 */ | |
9 | |
10 #ifdef HAVE_CONFIG_H | |
11 # include "config.h" | |
12 #endif | |
13 | |
14 | |
15 #include <stdio.h> | |
16 #include <string.h> | |
17 #include <unistd.h> | |
18 | |
19 #include <glib.h> | |
20 | |
21 #include "intl.h" | |
22 | |
23 #include "format_olympus.h" | |
24 #include "format_raw.h" | |
25 | |
26 #include "exif.h" | |
27 | |
28 | |
29 /* | |
30 *----------------------------------------------------------------------------- | |
101
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
31 * Raw ORF embedded jpeg extraction for Olympus |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
32 *----------------------------------------------------------------------------- |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
33 */ |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
34 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
35 static guint olympus_tiff_table(unsigned char *data, const guint len, guint offset, ExifByteOrder bo, |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
36 gint level, |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
37 guint *image_offset, guint *exif_offset); |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
38 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
39 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
40 static void olympus_tiff_entry(unsigned char *data, const guint len, guint offset, ExifByteOrder bo, |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
41 gint level, |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
42 guint *image_offset, guint *exif_offset) |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
43 { |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
44 guint tag; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
45 guint type; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
46 guint count; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
47 guint segment; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
48 guint seg_len; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
49 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
50 tag = exif_byte_get_int16(data + offset + EXIF_TIFD_OFFSET_TAG, bo); |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
51 type = exif_byte_get_int16(data + offset + EXIF_TIFD_OFFSET_FORMAT, bo); |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
52 count = exif_byte_get_int32(data + offset + EXIF_TIFD_OFFSET_COUNT, bo); |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
53 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
54 /* so far, we only care about tags with type long */ |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
55 if (type != EXIF_FORMAT_LONG_UNSIGNED && type != EXIF_FORMAT_LONG) return; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
56 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
57 seg_len = ExifFormatList[type].size * count; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
58 if (seg_len > 4) |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
59 { |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
60 segment = exif_byte_get_int32(data + offset + EXIF_TIFD_OFFSET_DATA, bo); |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
61 if (segment + seg_len > len) return; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
62 } |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
63 else |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
64 { |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
65 segment = offset + EXIF_TIFD_OFFSET_DATA; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
66 } |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
67 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
68 if (tag == 0x201) |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
69 { |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
70 /* start of embedded jpeg, not all olympus cameras embed a jpeg */ |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
71 *image_offset = exif_byte_get_int32(data + segment, bo); |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
72 } |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
73 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
74 if (tag == 0x8769) |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
75 { |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
76 /* This is the Exif info */ |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
77 *exif_offset = exif_byte_get_int32(data + segment, bo); |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
78 } |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
79 } |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
80 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
81 static guint olympus_tiff_table(unsigned char *data, const guint len, guint offset, ExifByteOrder bo, |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
82 gint level, |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
83 guint *image_offset, guint *exif_offset) |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
84 { |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
85 guint count; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
86 guint i; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
87 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
88 if (level > EXIF_TIFF_MAX_LEVELS) return 0; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
89 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
90 if (len < offset + 2) return FALSE; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
91 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
92 count = exif_byte_get_int16(data + offset, bo); |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
93 offset += 2; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
94 if (len < offset + count * EXIF_TIFD_SIZE + 4) return 0; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
95 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
96 for (i = 0; i < count; i++) |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
97 { |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
98 olympus_tiff_entry(data, len, offset + i * EXIF_TIFD_SIZE, bo, level, |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
99 image_offset, exif_offset); |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
100 } |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
101 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
102 return exif_byte_get_int32(data + offset + count * EXIF_TIFD_SIZE, bo); |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
103 } |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
104 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
105 gint format_olympus_raw(unsigned char *data, const guint len, |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
106 guint *image_offset, guint *exif_offset) |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
107 { |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
108 guint i_off = 0; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
109 guint e_off = 0; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
110 guint offset; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
111 gint level; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
112 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
113 if (len < 8) return FALSE; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
114 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
115 /* these are in tiff file format with a different magick header */ |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
116 if (memcmp(data, "IIR", 3) != 0) return FALSE; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
117 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
118 offset = exif_byte_get_int32(data + 4, EXIF_BYTE_ORDER_INTEL); |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
119 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
120 level = 0; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
121 while (offset && level < EXIF_TIFF_MAX_LEVELS) |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
122 { |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
123 offset = olympus_tiff_table(data, len, offset, EXIF_BYTE_ORDER_INTEL, 0, &i_off, &e_off); |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
124 level++; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
125 } |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
126 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
127 if (i_off != 0 || e_off != 0) |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
128 { |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
129 if (image_offset) *image_offset = i_off; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
130 if (exif_offset) *exif_offset = e_off; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
131 return TRUE; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
132 } |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
133 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
134 return FALSE; |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
135 } |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
136 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
137 |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
138 /* |
847e4bc6b54c
Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents:
100
diff
changeset
|
139 *----------------------------------------------------------------------------- |
57 | 140 * EXIF Makernote for Olympus |
141 *----------------------------------------------------------------------------- | |
142 */ | |
143 | |
144 static ExifTextList KonMinTagColorMode[]= { | |
145 { 0, "natural" }, | |
146 { 1, "black and white" }, | |
147 { 2, "vivid" }, | |
148 { 3, "solarization" }, | |
149 { 4, "Adobe RGB" }, | |
150 EXIF_TEXT_LIST_END | |
151 }; | |
152 | |
153 static ExifTextList KonMinTagQuality[]= { | |
154 { 0, "raw" }, | |
155 { 1, "super fine" }, | |
156 { 2, "find" }, | |
157 { 3, "standard" }, | |
158 { 4, "extra fine" }, | |
159 EXIF_TEXT_LIST_END | |
160 }; | |
161 | |
162 static ExifTextList OlympusTagJpegQuality[]= { | |
163 { 1, "standard" }, | |
164 { 2, "high" }, | |
165 { 3, "super high" }, | |
166 EXIF_TEXT_LIST_END | |
167 }; | |
168 | |
169 static ExifTextList OlympusTagMacro[]= { | |
170 { 0, "off" }, | |
171 { 1, "on" }, | |
172 { 2, "view" }, | |
173 { 3, "manual" }, | |
174 EXIF_TEXT_LIST_END | |
175 }; | |
176 | |
177 static ExifTextList OlympusTagFlashMode[]= { | |
178 { 0, "auto" }, | |
179 { 1, "red-eye reduction" }, | |
180 { 2, "fill" }, | |
181 { 3, "off" }, | |
182 EXIF_TEXT_LIST_END | |
183 }; | |
184 | |
185 static ExifTextList OlympusTagFocusMode[]= { | |
186 { 0, "auto" }, | |
187 { 1, "manual" }, | |
188 EXIF_TEXT_LIST_END | |
189 }; | |
190 | |
191 static ExifTextList OlympusTagSharpness[]= { | |
192 { 0, "normal" }, | |
193 { 1, "hard" }, | |
194 { 2, "soft" }, | |
195 EXIF_TEXT_LIST_END | |
196 }; | |
197 | |
198 static ExifTextList OlympusTagContrast[]= { | |
199 { 0, "hard" }, | |
200 { 1, "normal" }, | |
201 { 2, "soft" }, | |
202 EXIF_TEXT_LIST_END | |
203 }; | |
204 | |
205 #if 0 | |
206 static ExifTextList OlympusTag[]= { | |
207 { , "" }, | |
208 { , "" }, | |
209 EXIF_TEXT_LIST_END | |
210 }; | |
211 #endif | |
212 | |
213 | |
214 static ExifMarker OlympusExifMarkersList[] = { | |
215 { 0x0001, EXIF_FORMAT_LONG_UNSIGNED, -1, "Konica/MinoltaSettings", "Konica / Minolta settings", NULL }, | |
216 { 0x0003, EXIF_FORMAT_LONG_UNSIGNED, -1, "Konica/MinoltaSettings", "Konica / Minolta settings", NULL }, | |
217 { 0x0040, EXIF_FORMAT_LONG_UNSIGNED, -1, "CompressedImageSize", "Compressed image size", NULL }, | |
218 { 0x0081, EXIF_FORMAT_LONG_UNSIGNED, 1, "ThumbnailOffset", "Thumbnail offset", NULL }, | |
219 { 0x0088, EXIF_FORMAT_LONG_UNSIGNED, 1, "ThumbnailOffset", "Thumbnail offset", NULL }, | |
220 { 0x0089, EXIF_FORMAT_LONG_UNSIGNED, 1, "ThumbnailLength", "Thumbnail length", NULL }, | |
221 { 0x0101, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Konica/Minolta.ColorMode", "Color mode", KonMinTagColorMode }, | |
222 { 0x0102, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Konica/Minolta.Quality", "Quality", KonMinTagQuality }, | |
223 { 0x0103, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Konica/Minolta.Quality", "Quality", KonMinTagQuality }, | |
224 { 0x0200, EXIF_FORMAT_LONG_UNSIGNED, 3, "Olympus.SpecialMode", "Special mode", NULL }, | |
225 { 0x0201, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.JpegQuality", "Jpeg quality", OlympusTagJpegQuality }, | |
226 { 0x0202, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.Macro", "Macro", OlympusTagMacro }, | |
227 { 0x0204, EXIF_FORMAT_RATIONAL_UNSIGNED, 1, "Olympus.DigitalZoom", "Digital zoom", NULL }, | |
228 { 0x0207, EXIF_FORMAT_STRING, -1, "Olympus.Firmware", "Firmware version", NULL }, | |
229 { 0x0208, EXIF_FORMAT_STRING, -1, "Olympus.PictureInfo", "Picture info", NULL }, | |
230 { 0x0209, EXIF_FORMAT_UNDEFINED, -1, "Olympus.CameraID", "Camera ID", NULL }, | |
231 { 0x020b, EXIF_FORMAT_LONG_UNSIGNED, 1, "Epson.ImageWidth", "Image width", NULL }, | |
232 { 0x020c, EXIF_FORMAT_LONG_UNSIGNED, 1, "Epson.ImageHeight", "Image height", NULL }, | |
233 { 0x020d, EXIF_FORMAT_STRING, -1, "Epson.Manufacturer", "Manufacturer", NULL }, | |
234 { 0x0e00, EXIF_FORMAT_BYTE, -1, "Olympus.PrintImageMatching", "Print image matching", NULL }, | |
235 { 0x1004, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.FlashMode", "Flash mode", OlympusTagFlashMode }, | |
100
deafec7cd99f
Mon Nov 6 20:53:22 2006 John Ellis <johne@verizon.net>
gqview
parents:
58
diff
changeset
|
236 { 0x1006, EXIF_FORMAT_RATIONAL, 1, "Olympus.Bracket", "Bracket", NULL }, |
57 | 237 { 0x100b, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.FocusMode", "Focus mode", OlympusTagFocusMode }, |
100
deafec7cd99f
Mon Nov 6 20:53:22 2006 John Ellis <johne@verizon.net>
gqview
parents:
58
diff
changeset
|
238 { 0x100c, EXIF_FORMAT_RATIONAL_UNSIGNED, 1, "Olympus.FocusDistance", "Focus distance", NULL }, |
57 | 239 { 0x100d, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.Zoom", "Zoom", NULL }, |
240 { 0x1006, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.MacroFocus", "Macro focus", NULL }, | |
241 { 0x100f, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.Sharpness", "Sharpness", OlympusTagSharpness }, | |
242 { 0x1011, EXIF_FORMAT_SHORT_UNSIGNED, 9, "Olympus.ColorMatrix", "Color matrix", NULL }, | |
243 { 0x1012, EXIF_FORMAT_SHORT_UNSIGNED, 4, "Olympus.BlackLevel", "Black level", NULL }, | |
244 { 0x1015, EXIF_FORMAT_SHORT_UNSIGNED, 2, "Olympus.WhiteBalance", "White balance", NULL }, | |
245 { 0x1017, EXIF_FORMAT_SHORT_UNSIGNED, 2, "Olympus.RedBias", "Red bias", NULL }, | |
246 { 0x1018, EXIF_FORMAT_SHORT_UNSIGNED, 2, "Olympus.BlueBias", "Blue bias", NULL }, | |
100
deafec7cd99f
Mon Nov 6 20:53:22 2006 John Ellis <johne@verizon.net>
gqview
parents:
58
diff
changeset
|
247 { 0x101a, EXIF_FORMAT_STRING, -1, "Olympus.SerialNumber", "Serial number", NULL }, |
deafec7cd99f
Mon Nov 6 20:53:22 2006 John Ellis <johne@verizon.net>
gqview
parents:
58
diff
changeset
|
248 { 0x1023, EXIF_FORMAT_RATIONAL, 1, "Olympus.FlashBias", "Flash bias", NULL }, |
57 | 249 { 0x1029, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.Contrast", "Contrast", OlympusTagContrast }, |
250 { 0x102a, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.SharpnessFactor", "Sharpness factor", NULL }, | |
251 { 0x102b, EXIF_FORMAT_SHORT_UNSIGNED, 6, "Olympus.ColorControl", "Color control", NULL }, | |
252 { 0x102c, EXIF_FORMAT_SHORT_UNSIGNED, 2, "Olympus.ValidBits", "Valid bits", NULL }, | |
253 { 0x102d, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.CoringFilter", "Coring filter", NULL }, | |
254 { 0x102e, EXIF_FORMAT_LONG_UNSIGNED, 1, "Olympus.FinalWidth", "Final width", NULL }, | |
255 { 0x102f, EXIF_FORMAT_LONG_UNSIGNED, 1, "Olympus.FinalHeight", "Final height", NULL }, | |
256 { 0x1034, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Olympus.CompressionRatio", "Compression ratio", NULL }, | |
257 EXIF_MARKER_LIST_END | |
258 }; | |
259 | |
260 static ExifTextList OlympusShootingMode[]= { | |
261 { 0, "normal" }, | |
262 { 1, "unknown" }, | |
263 { 2, "fast" }, | |
264 { 3, "panorama" }, | |
265 EXIF_TEXT_LIST_END | |
266 }; | |
267 | |
268 static ExifTextList OlympusPanoramaDirection[]= { | |
269 { 1, "left to right" }, | |
270 { 2, "right to left" }, | |
271 { 3, "bottom to top" }, | |
272 { 4, "top to bottom" }, | |
273 EXIF_TEXT_LIST_END | |
274 }; | |
275 | |
276 static ExifTextList OlympusWB[]= { | |
277 { 1, "auto" }, | |
278 { 2, "manual" }, | |
279 { 3, "one-touch" }, | |
280 EXIF_TEXT_LIST_END | |
281 }; | |
282 | |
283 static ExifTextList OlympusWBColorTemp[]= { | |
284 { 2, "3000" }, | |
285 { 3, "3700" }, | |
286 { 4, "4000" }, | |
287 { 5, "4500" }, | |
288 { 6, "5500" }, | |
289 { 7, "6500" }, | |
290 { 8, "7500" }, | |
291 EXIF_TEXT_LIST_END | |
292 }; | |
293 | |
294 gint format_olympus_makernote(ExifData *exif, unsigned char *tiff, guint offset, | |
295 guint size, ExifByteOrder bo) | |
296 { | |
297 unsigned char *data; | |
298 ExifItem *item; | |
299 | |
300 if (offset + 8 + 4 >= size) return FALSE; | |
301 | |
302 data = tiff + offset; | |
303 | |
304 /* Olympus tag format starts with "OLYMP\x00\x01" or "OLYMP\x00\x02", | |
305 * plus an unknown byte, | |
306 * followed by IFD data using Olympus tags. | |
307 */ | |
308 if (memcmp(data, "OLYMP\x00\x01", 7) != 0 && | |
309 memcmp(data, "OLYMP\x00\x02", 7) != 0) return FALSE; | |
310 | |
311 if (exif_parse_IFD_table(exif, tiff, offset + 8, size, | |
312 bo, 0, OlympusExifMarkersList) != 0) | |
313 { | |
314 return FALSE; | |
315 } | |
316 | |
317 item = exif_get_item(exif, "Olympus.SpecialMode"); | |
318 if (item && item->data_len == 3 * sizeof(guint32)) | |
319 { | |
320 static ExifMarker marker = { 0x0200, EXIF_FORMAT_STRING, -1, | |
321 "Olympus.ShootingMode", "Shooting mode", NULL }; | |
322 guint32 *array = item->data; | |
58
df73b94154e4
Sat Jun 11 01:06:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
57
diff
changeset
|
323 gchar *mode; |
df73b94154e4
Sat Jun 11 01:06:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
57
diff
changeset
|
324 gchar *pdir = NULL; |
57 | 325 gchar *text; |
326 gint l; | |
327 | |
328 mode = exif_text_list_find_value(OlympusShootingMode, array[0]); | |
329 if (array[0] == 3) | |
330 { | |
331 pdir = exif_text_list_find_value(OlympusPanoramaDirection, array[2]); | |
332 } | |
333 | |
58
df73b94154e4
Sat Jun 11 01:06:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
57
diff
changeset
|
334 text = g_strdup_printf("%s%s%s, seq %d", mode, |
57 | 335 (pdir) ? " " : "", (pdir) ? pdir : "", |
336 array[1] + 1); | |
337 l = strlen(text) + 1; | |
338 item = exif_item_new(marker.format, marker.tag, l, &marker); | |
339 memcpy(item->data, text, l); | |
58
df73b94154e4
Sat Jun 11 01:06:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
57
diff
changeset
|
340 |
57 | 341 g_free(text); |
58
df73b94154e4
Sat Jun 11 01:06:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
57
diff
changeset
|
342 g_free(pdir); |
df73b94154e4
Sat Jun 11 01:06:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
57
diff
changeset
|
343 g_free(mode); |
57 | 344 |
345 exif->items = g_list_prepend(exif->items, item); | |
346 } | |
347 | |
348 item = exif_get_item(exif, "Olympus.WhiteBalance"); | |
349 if (item && item->data_len == 2 * sizeof(guint16)) | |
350 { | |
351 static ExifMarker marker = { 0x1015, EXIF_FORMAT_STRING, -1, | |
352 "Olympus.WhiteBalance", "White balance", NULL }; | |
353 guint16 *array = item->data; | |
58
df73b94154e4
Sat Jun 11 01:06:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
57
diff
changeset
|
354 gchar *mode; |
df73b94154e4
Sat Jun 11 01:06:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
57
diff
changeset
|
355 gchar *color = NULL; |
57 | 356 gchar *text; |
357 gint l; | |
358 | |
359 mode = exif_text_list_find_value(OlympusWB, array[0]); | |
360 if (array[0] == 2) | |
361 { | |
362 color = exif_text_list_find_value(OlympusWBColorTemp, array[1]); | |
363 } | |
364 | |
58
df73b94154e4
Sat Jun 11 01:06:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
57
diff
changeset
|
365 text = g_strdup_printf("%s%s%s", mode, |
57 | 366 (color) ? " " : "", (color) ? color : ""); |
367 l = strlen(text) + 1; | |
368 item = exif_item_new(marker.format, marker.tag, l, &marker); | |
369 memcpy(item->data, text, l); | |
58
df73b94154e4
Sat Jun 11 01:06:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
57
diff
changeset
|
370 |
57 | 371 g_free(text); |
58
df73b94154e4
Sat Jun 11 01:06:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
57
diff
changeset
|
372 g_free(color); |
df73b94154e4
Sat Jun 11 01:06:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
57
diff
changeset
|
373 g_free(mode); |
57 | 374 |
375 exif->items = g_list_prepend(exif->items, item); | |
376 } | |
377 | |
378 return TRUE; | |
379 } | |
380 | |
381 |