annotate src/format_raw.c @ 1723:25471efb11ba

print text using pango renderer - the text is sent to postscript as a bitmap - this fixes printing of non-ascii characters http://sourceforge.net/tracker/index.php?func=detail&aid=2836135&group_id=222125&atid=1054680
author nadvornik
date Sat, 26 Sep 2009 08:47:28 +0000
parents bc3f5c0432f6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
43
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
1 /*
541
116346636d42 Replace GQView by Geeqie.
zas_
parents: 507
diff changeset
2 * Geeqie
116346636d42 Replace GQView by Geeqie.
zas_
parents: 507
diff changeset
3 * (C) 2006 John Ellis
1284
8b89e3ff286b Add year 2009 to copyright info everywhere.
zas_
parents: 1187
diff changeset
4 * Copyright (C) 2008 - 2009 The Geeqie Team
43
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
5 *
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
6 * Authors:
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
7 * Original version 2005 Lars Ellenberg, base on dcraw by David coffin.
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
8 *
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
9 * This software is released under the GNU General Public License (GNU GPL).
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
10 * Please read the included file COPYING for more information.
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
11 * This software comes with no warranty of any kind, use at your own risk!
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
12 */
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
13
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
14 #ifdef HAVE_CONFIG_H
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
15 # include "config.h"
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
16 #endif
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
17
177
0ca3b4c8ffae started exiv2 integration
nadvornik
parents: 138
diff changeset
18 #ifndef HAVE_EXIV2
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
19
43
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
20 #include <stdio.h>
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
21 #include <string.h>
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
22 #include <unistd.h>
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
23 #include <sys/types.h>
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
24 #include <sys/stat.h>
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
25 #include <sys/mman.h>
43
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
26
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
27 #include <glib.h>
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
28
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
29 #include "intl.h"
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
30
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 277
diff changeset
31 #include "main.h"
43
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
32 #include "format_raw.h"
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
33
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
34 #include "format_canon.h"
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
35 #include "format_fuji.h"
51
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
36 #include "format_nikon.h"
57
a8c9992320f4 Fri Jun 10 20:57:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 54
diff changeset
37 #include "format_olympus.h"
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
38
53
00843150f7c8 Tue Jun 7 03:47:03 2005 John Ellis <johne@verizon.net>
gqview
parents: 51
diff changeset
39
51
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
40 typedef struct _FormatRawEntry FormatRawEntry;
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
41 struct _FormatRawEntry {
54
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
42 const gchar *extension;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
43 FormatRawMatchType magic_type;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
44 const guint magic_offset;
1003
4bfee4a63f86 const gpointer -> gconstpointer.
zas_
parents: 1002
diff changeset
45 gconstpointer magic_pattern;
54
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
46 const guint magic_length;
101
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
47 const FormatRawExifType exif_type;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
48 FormatRawExifParseFunc exif_func;
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
49 const gchar *description;
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
50 FormatRawParseFunc func_parse;
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
51 };
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
52
51
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
53 static FormatRawEntry format_raw_list[] = {
101
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
54 #if DEBUG_RAW_TIFF
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
55 FORMAT_RAW_DEBUG_TIFF,
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
56 #endif
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
57 FORMAT_RAW_CANON,
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
58 FORMAT_RAW_FUJI,
53
00843150f7c8 Tue Jun 7 03:47:03 2005 John Ellis <johne@verizon.net>
gqview
parents: 51
diff changeset
59 FORMAT_RAW_NIKON,
101
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
60 FORMAT_RAW_OLYMPUS,
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
61 FORMAT_RAW_PENTAX,
277
9de0f88b2b91 Add support for some Samsung raw files (.pef).
zas_
parents: 227
diff changeset
62 FORMAT_RAW_SAMSUNG,
101
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
63 { NULL, 0, 0, NULL, 0, 0, NULL, NULL, NULL }
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
64 };
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
65
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
66
51
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
67 typedef struct _FormatExifEntry FormatExifEntry;
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
68 struct _FormatExifEntry {
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
69 FormatExifMatchType header_type;
1003
4bfee4a63f86 const gpointer -> gconstpointer.
zas_
parents: 1002
diff changeset
70 gconstpointer header_pattern;
51
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
71 const guint header_length;
53
00843150f7c8 Tue Jun 7 03:47:03 2005 John Ellis <johne@verizon.net>
gqview
parents: 51
diff changeset
72 const gchar *description;
51
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
73 FormatExifParseFunc func_parse;
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
74 };
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
75
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
76 static FormatExifEntry format_exif_list[] = {
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
77 FORMAT_EXIF_CANON,
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
78 FORMAT_EXIF_FUJI,
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
79 FORMAT_EXIF_NIKON,
57
a8c9992320f4 Fri Jun 10 20:57:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 54
diff changeset
80 FORMAT_EXIF_OLYMPUS,
749
f606e8962329 Silent few warnings that appeared when using --disable-exiv2 configure option.
zas_
parents: 673
diff changeset
81 { 0, NULL, 0, NULL, NULL }
51
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
82 };
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
83
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
84
1000
4fe8f9656107 For the sake of consistency, use glib basic types everywhere.
zas_
parents: 749
diff changeset
85 static guint tiff_table(guchar *data, const guint len, guint offset, ExifByteOrder bo,
54
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
86 guint tag, ExifFormatType type,
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
87 guint *result_offset, guint *result_count)
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
88 {
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
89 guint count;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
90 guint i;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
91
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
92 if (len < offset + 2) return 0;
1187
3a27afa693bd Fix up unsigned expression always true warning.
zas_
parents: 1055
diff changeset
93 if (type > EXIF_FORMAT_COUNT) return 0;
54
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
94
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
95 count = exif_byte_get_int16(data + offset, bo);
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
96 offset += 2;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
97 if (len < offset + count * 12 + 4) return 0;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
98
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
99 for (i = 0; i < count; i++)
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
100 {
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
101 guint segment;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
102
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
103 segment = offset + i * 12;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
104 if (exif_byte_get_int16(data + segment, bo) == tag &&
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
105 exif_byte_get_int16(data + segment + 2, bo) == type)
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
106 {
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
107 guint chunk_count;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
108 guint chunk_offset;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
109 guint chunk_length;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
110
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
111 chunk_count = exif_byte_get_int32(data + segment + 4, bo);
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
112 chunk_length = ExifFormatList[type].size * chunk_count;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
113
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
114 if (chunk_length > 4)
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
115 {
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
116 chunk_offset = exif_byte_get_int32(data + segment + 8, bo);
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
117 }
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
118 else
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
119 {
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
120 chunk_offset = segment + 8;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
121 }
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
122
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
123 if (chunk_offset + chunk_length <= len)
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
124 {
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
125 *result_offset = chunk_offset;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
126 *result_count = chunk_count;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
127 }
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
128
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
129 return 0;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
130 }
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
131 }
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
132
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
133 return exif_byte_get_int32(data + offset + count * 12, bo);
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
134 }
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
135
1453
bc3f5c0432f6 gint -> gboolean where applicable. The end (ouf!).
zas_
parents: 1437
diff changeset
136 static gboolean format_tiff_find_tag_data(guchar *data, const guint len,
bc3f5c0432f6 gint -> gboolean where applicable. The end (ouf!).
zas_
parents: 1437
diff changeset
137 guint tag, ExifFormatType type,
bc3f5c0432f6 gint -> gboolean where applicable. The end (ouf!).
zas_
parents: 1437
diff changeset
138 guint *result_offset, guint *result_count)
54
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
139 {
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
140 ExifByteOrder bo;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
141 guint offset;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
142
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
143 if (len < 8) return FALSE;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
144
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
145 if (memcmp(data, "II", 2) == 0)
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
146 {
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
147 bo = EXIF_BYTE_ORDER_INTEL;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
148 }
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
149 else if (memcmp(data, "MM", 2) == 0)
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
150 {
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
151 bo = EXIF_BYTE_ORDER_MOTOROLA;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
152 }
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
153 else
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
154 {
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
155 return FALSE;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
156 }
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
157
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
158 if (exif_byte_get_int16(data + 2, bo) != 0x002A)
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
159 {
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
160 return FALSE;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
161 }
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
162
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
163 offset = exif_byte_get_int32(data + 4, bo);
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
164
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
165 while (offset != 0)
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
166 {
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
167 guint ro = 0;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
168 guint rc = 0;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
169
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
170 offset = tiff_table(data, len, offset, bo, tag, type, &ro, &rc);
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
171 if (ro != 0)
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
172 {
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
173 *result_offset = ro;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
174 *result_count = rc;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
175 return TRUE;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
176 }
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
177 }
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
178
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
179 return FALSE;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
180 }
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
181
1000
4fe8f9656107 For the sake of consistency, use glib basic types everywhere.
zas_
parents: 749
diff changeset
182 static FormatRawEntry *format_raw_find(guchar *data, const guint len)
43
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
183 {
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
184 gint n;
1453
bc3f5c0432f6 gint -> gboolean where applicable. The end (ouf!).
zas_
parents: 1437
diff changeset
185 gboolean tiff;
54
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
186 guint make_count = 0;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
187 guint make_offset = 0;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
188
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
189 tiff = (len > 8 &&
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
190 (memcmp(data, "II\x2a\x00", 4) == 0 ||
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
191 memcmp(data, "MM\x00\x2a", 4) == 0));
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
192
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
193 n = 0;
54
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
194 while (format_raw_list[n].magic_pattern)
43
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
195 {
54
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
196 FormatRawEntry *entry = &format_raw_list[n];
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
197
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
198 switch (entry->magic_type)
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
199 {
54
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
200 case FORMAT_RAW_MATCH_MAGIC:
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
201 if (entry->magic_length + entry->magic_offset <= len &&
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
202 memcmp(data + entry->magic_offset,
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
203 entry->magic_pattern, entry->magic_length) == 0)
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
204 {
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
205 return entry;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
206 }
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
207 break;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
208 case FORMAT_RAW_MATCH_TIFF_MAKE:
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
209 if (tiff &&
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
210 make_offset == 0 &&
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
211 !format_tiff_find_tag_data(data, len, 0x10f, EXIF_FORMAT_STRING,
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
212 &make_offset, &make_count))
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
213 {
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
214 tiff = FALSE;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
215 }
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
216 if (make_offset != 0 &&
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
217 make_count >= entry->magic_offset + entry->magic_length &&
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
218 memcmp(entry->magic_pattern,
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
219 data + make_offset + entry->magic_offset, entry->magic_length) == 0)
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
220 {
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
221 return entry;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
222 }
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
223 break;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
224 default:
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
225 break;
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
226 }
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
227 n++;
43
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
228 }
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
229
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
230 return NULL;
43
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
231 }
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
232
1453
bc3f5c0432f6 gint -> gboolean where applicable. The end (ouf!).
zas_
parents: 1437
diff changeset
233 static gboolean format_raw_parse(FormatRawEntry *entry,
bc3f5c0432f6 gint -> gboolean where applicable. The end (ouf!).
zas_
parents: 1437
diff changeset
234 guchar *data, const guint len,
bc3f5c0432f6 gint -> gboolean where applicable. The end (ouf!).
zas_
parents: 1437
diff changeset
235 guint *image_offset, guint *exif_offset)
43
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
236 {
46
905f8fa583a3 Thu May 26 22:14:53 2005 John Ellis <johne@verizon.net>
gqview
parents: 45
diff changeset
237 guint io = 0;
905f8fa583a3 Thu May 26 22:14:53 2005 John Ellis <johne@verizon.net>
gqview
parents: 45
diff changeset
238 guint eo = 0;
1453
bc3f5c0432f6 gint -> gboolean where applicable. The end (ouf!).
zas_
parents: 1437
diff changeset
239 gboolean found;
43
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
240
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
241 if (!entry || !entry->func_parse) return FALSE;
43
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
242
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
243 DEBUG_1("RAW using file parser for %s", entry->description);
53
00843150f7c8 Tue Jun 7 03:47:03 2005 John Ellis <johne@verizon.net>
gqview
parents: 51
diff changeset
244
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
245 found = entry->func_parse(data, len, &io, &eo);
43
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
246
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
247 if (!found ||
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
248 io >= len - 4 ||
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
249 eo >= len)
43
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
250 {
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
251 return FALSE;
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
252 }
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
253
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
254 if (image_offset) *image_offset = io;
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
255 if (exif_offset) *exif_offset = eo;
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
256
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
257 return TRUE;
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
258 }
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
259
1453
bc3f5c0432f6 gint -> gboolean where applicable. The end (ouf!).
zas_
parents: 1437
diff changeset
260 gboolean format_raw_img_exif_offsets(guchar *data, const guint len,
bc3f5c0432f6 gint -> gboolean where applicable. The end (ouf!).
zas_
parents: 1437
diff changeset
261 guint *image_offset, guint *exif_offset)
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
262 {
51
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
263 FormatRawEntry *entry;
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
264
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
265 if (!data || len < 1) return FALSE;
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
266
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
267 entry = format_raw_find(data, len);
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
268
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
269 if (!entry || !entry->func_parse) return FALSE;
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
270
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
271 return format_raw_parse(entry, data, len, image_offset, exif_offset);
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
272 }
43
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
273
ee03f36e9e4b Sun May 15 21:40:26 2005 John Ellis <johne@verizon.net>
gqview
parents:
diff changeset
274
1000
4fe8f9656107 For the sake of consistency, use glib basic types everywhere.
zas_
parents: 749
diff changeset
275 FormatRawExifType format_raw_exif_offset(guchar *data, const guint len, guint *exif_offset,
101
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
276 FormatRawExifParseFunc *exif_parse_func)
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
277 {
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
278 FormatRawEntry *entry;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
279
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
280 if (!data || len < 1) return FALSE;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
281
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
282 entry = format_raw_find(data, len);
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
283
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
284 if (!entry || !entry->func_parse) return FALSE;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
285
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
286 if (!format_raw_parse(entry, data, len, NULL, exif_offset)) return FORMAT_RAW_EXIF_NONE;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
287
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
288 if (entry->exif_type == FORMAT_RAW_EXIF_PROPRIETARY && exif_parse_func)
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
289 {
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
290 *exif_parse_func = entry->exif_func;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
291 }
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
292
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
293 return entry->exif_type;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
294 }
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
295
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
296
1453
bc3f5c0432f6 gint -> gboolean where applicable. The end (ouf!).
zas_
parents: 1437
diff changeset
297 gboolean format_raw_img_exif_offsets_fd(gint fd, const gchar *path,
bc3f5c0432f6 gint -> gboolean where applicable. The end (ouf!).
zas_
parents: 1437
diff changeset
298 guchar *header_data, const guint header_len,
bc3f5c0432f6 gint -> gboolean where applicable. The end (ouf!).
zas_
parents: 1437
diff changeset
299 guint *image_offset, guint *exif_offset)
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
300 {
51
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
301 FormatRawEntry *entry;
1002
3096a47232ec Use gpointer instead of void *.
zas_
parents: 1000
diff changeset
302 gpointer map_data = NULL;
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
303 size_t map_len = 0;
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
304 struct stat st;
1453
bc3f5c0432f6 gint -> gboolean where applicable. The end (ouf!).
zas_
parents: 1437
diff changeset
305 gboolean success;
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
306
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
307 if (!header_data || fd < 0) return FALSE;
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
308
54
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
309 /* given image pathname, first do simple (and fast) file extension test */
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
310 if (path)
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
311 {
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
312 const gchar *ext;
1437
a3d3208b0c50 gint -> gboolean.
zas_
parents: 1307
diff changeset
313 gboolean match = FALSE;
54
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
314 gint i;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
315
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
316 ext = strrchr(path, '.');
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
317 if (!ext) return FALSE;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
318 ext++;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
319
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
320 i = 0;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
321 while (!match && format_raw_list[i].magic_pattern)
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
322 {
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
323 if (format_raw_list[i].extension &&
1307
e8f21b91885d Glibification again.
zas_
parents: 1284
diff changeset
324 g_ascii_strcasecmp(format_raw_list[i].extension, ext) == 0)
54
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
325 {
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
326 match = TRUE;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
327 }
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
328 i++;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
329 }
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
330
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
331 if (!match) return FALSE;
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
332
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
333 DEBUG_1("RAW file parser extension match");
54
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
334 }
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
335
59
57f6da2510d9 Sun Jun 12 19:25:26 2005 John Ellis <johne@verizon.net>
gqview
parents: 57
diff changeset
336 /* FIXME:
57f6da2510d9 Sun Jun 12 19:25:26 2005 John Ellis <johne@verizon.net>
gqview
parents: 57
diff changeset
337 * when the target is a tiff file it should be mmaped prior to format_raw_find as
57f6da2510d9 Sun Jun 12 19:25:26 2005 John Ellis <johne@verizon.net>
gqview
parents: 57
diff changeset
338 * the make field data may not always be within header_data + header_len
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 281
diff changeset
339 */
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
340 entry = format_raw_find(header_data, header_len);
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
341
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
342 if (!entry || !entry->func_parse) return FALSE;
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
343
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
344 if (fstat(fd, &st) == -1)
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
345 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
346 log_printf("Failed to stat file %d\n", fd);
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
347 return FALSE;
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
348 }
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
349 map_len = st.st_size;
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
350 map_data = mmap(0, map_len, PROT_READ, MAP_PRIVATE, fd, 0);
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
351 if (map_data == MAP_FAILED)
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
352 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
353 log_printf("Failed to mmap file %d\n", fd);
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
354 return FALSE;
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
355 }
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
356
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
357 success = format_raw_parse(entry, map_data, map_len, image_offset, exif_offset);
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
358
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
359 if (munmap(map_data, map_len) == -1)
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
360 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
361 log_printf("Failed to unmap file %d\n", fd);
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
362 }
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
363
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
364 if (success && image_offset)
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
365 {
749
f606e8962329 Silent few warnings that appeared when using --disable-exiv2 configure option.
zas_
parents: 673
diff changeset
366 if (lseek(fd, *image_offset, SEEK_SET) != (off_t) *image_offset)
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
367 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
368 log_printf("Failed to seek to embedded image\n");
45
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
369
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
370 *image_offset = 0;
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
371 if (*exif_offset) *exif_offset = 0;
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
372 success = FALSE;
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
373 }
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
374 }
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
375
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
376 return success;
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
377 }
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
378
7cfa60beda76 Thu May 26 13:57:19 2005 John Ellis <johne@verizon.net>
gqview
parents: 43
diff changeset
379
1000
4fe8f9656107 For the sake of consistency, use glib basic types everywhere.
zas_
parents: 749
diff changeset
380 static FormatExifEntry *format_exif_makernote_find(ExifData *exif, guchar *tiff,
51
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
381 guint offset, guint size)
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
382 {
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
383 ExifItem *make;
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
384 gint n;
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
385
181
c01dd7c9c7dc unified tag names between exiv2 and internal rxif parser
nadvornik
parents: 177
diff changeset
386 make = exif_get_item(exif, "Exif.Image.Make");
51
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
387
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
388 n = 0;
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
389 while (format_exif_list[n].header_pattern)
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
390 {
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
391 switch (format_exif_list[n].header_type)
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
392 {
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
393 case FORMAT_EXIF_MATCH_MAKERNOTE:
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
394 if (format_exif_list[n].header_length + offset < size &&
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
395 memcmp(tiff + offset, format_exif_list[n].header_pattern,
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
396 format_exif_list[n].header_length) == 0)
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
397 {
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
398 return &format_exif_list[n];
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
399 }
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
400 break;
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
401 case FORMAT_EXIF_MATCH_MAKE:
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
402 if (make &&
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
403 make->data_len >= format_exif_list[n].header_length &&
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
404 memcmp(make->data, format_exif_list[n].header_pattern,
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
405 format_exif_list[n].header_length) == 0)
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
406 {
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
407 return &format_exif_list[n];
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
408 }
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
409 break;
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
410 }
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
411 n++;
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
412 }
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
413
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
414 return FALSE;
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
415 }
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
416
1453
bc3f5c0432f6 gint -> gboolean where applicable. The end (ouf!).
zas_
parents: 1437
diff changeset
417 gboolean format_exif_makernote_parse(ExifData *exif, guchar *tiff, guint offset,
bc3f5c0432f6 gint -> gboolean where applicable. The end (ouf!).
zas_
parents: 1437
diff changeset
418 guint size, ExifByteOrder bo)
51
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
419 {
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
420 FormatExifEntry *entry;
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
421
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
422 entry = format_exif_makernote_find(exif, tiff, offset, size);
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
423
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
424 if (!entry || !entry->func_parse) return FALSE;
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
425
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
426 DEBUG_1("EXIF using makernote parser for %s", entry->description);
53
00843150f7c8 Tue Jun 7 03:47:03 2005 John Ellis <johne@verizon.net>
gqview
parents: 51
diff changeset
427
54
b58cac75ad12 Thu Jun 9 22:23:18 2005 John Ellis <johne@verizon.net>
gqview
parents: 53
diff changeset
428 return entry->func_parse(exif, tiff, offset, size, bo);
51
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
429 }
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
430
101
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
431 /*
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
432 *-----------------------------------------------------------------------------
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
433 * Basic TIFF debugger, prints all IFD entries within tiff file
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
434 *-----------------------------------------------------------------------------
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
435 */
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
436 #if DEBUG_RAW_TIFF
51
276ea4c98d33 Sat Jun 4 22:24:00 2005 John Ellis <johne@verizon.net>
gqview
parents: 47
diff changeset
437
1000
4fe8f9656107 For the sake of consistency, use glib basic types everywhere.
zas_
parents: 749
diff changeset
438 static guint format_debug_tiff_table(guchar *data, const guint len, guint offset,
101
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
439 ExifByteOrder bo, gint level);
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
440
1000
4fe8f9656107 For the sake of consistency, use glib basic types everywhere.
zas_
parents: 749
diff changeset
441 static void format_debug_tiff_entry(guchar *data, const guint len, guint offset,
101
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
442 ExifByteOrder bo, gint level)
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
443 {
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
444 guint tag;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
445 guint type;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
446 guint count;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
447 guint segment;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
448 guint seg_len;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
449
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
450 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: 59
diff changeset
451 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: 59
diff changeset
452 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: 59
diff changeset
453
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
454 seg_len = ExifFormatList[type].size * count;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
455 if (seg_len > 4)
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
456 {
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
457 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: 59
diff changeset
458 if (segment + seg_len > len) return;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
459 }
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
460 else
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
461 {
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
462 segment = offset + EXIF_TIFD_OFFSET_DATA;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
463 }
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
464
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
465 log_printf("%*stag:0x%04X (%05d), type:%2d %9s, len:%6d [%02X %02X %02X %02X] @ offset:%d\n",
101
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
466 level, "", tag, tag, type,
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
467 (type < EXIF_FORMAT_COUNT) ? ExifFormatList[type].short_name : "???", count,
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
468 data[segment], data[segment + 1], data[segment + 2], data[segment + 3], segment);
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
469
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
470 if (tag == 0x8769 || tag == 0x14a)
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
471 {
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
472 gint i;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
473
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
474 log_printf("%*s~~~ found %s table\n", level, "", (tag == 0x14a) ? "subIFD" : "EXIF" );
101
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
475
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
476 for (i = 0; i < count; i++)
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
477 {
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
478 guint subset;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
479
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
480 subset = exif_byte_get_int32(data + segment + i * 4, bo);
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
481 format_debug_tiff_table(data, len, subset, bo, level + 1);
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
482 }
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
483 }
114
50fc73e08550 Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents: 101
diff changeset
484 else if (tag == 0x8773 && type == EXIF_FORMAT_UNDEFINED)
50fc73e08550 Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents: 101
diff changeset
485 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
486 log_printf("%*s~~~ found ICC color profile at offset %d, length %d\n", level, "", segment, seg_len);
114
50fc73e08550 Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents: 101
diff changeset
487 }
101
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
488 else if (tag == 0x201 && (type == EXIF_FORMAT_LONG_UNSIGNED || type == EXIF_FORMAT_LONG))
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
489 {
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
490 guint subset = exif_byte_get_int32(data + segment, bo);
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
491 log_printf("%*s~~~ found jpeg data at offset %d\n", level, "", subset);
101
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
492 }
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
493 else if (tag == 0x202 && (type == EXIF_FORMAT_LONG_UNSIGNED || type == EXIF_FORMAT_LONG))
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
494 {
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
495 guint subset = exif_byte_get_int32(data + segment, bo);
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
496 log_printf("%*s~~~ found jpeg data length of %d\n", level, "", subset);
101
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
497 }
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
498 }
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
499
1000
4fe8f9656107 For the sake of consistency, use glib basic types everywhere.
zas_
parents: 749
diff changeset
500 static guint format_debug_tiff_table(guchar *data, const guint len, guint offset,
101
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
501 ExifByteOrder bo, gint level)
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
502 {
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
503 guint count;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
504 guint i;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
505
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
506 if (level > EXIF_TIFF_MAX_LEVELS) return 0;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
507
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
508 if (len < offset + 2) return FALSE;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
509
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
510 count = exif_byte_get_int16(data + offset, bo);
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
511 offset += 2;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
512 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: 59
diff changeset
513
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
514 log_printf("%*s== tiff table #%d has %d entries ==\n", level, "", level, count);
101
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
515
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
516 for (i = 0; i < count; i++)
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
517 {
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
518 format_debug_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: 59
diff changeset
519 }
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
520
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
521 log_printf("%*s----------- end of #%d ------------\n", level, "", level);
101
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
522
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
523 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: 59
diff changeset
524 }
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
525
1453
bc3f5c0432f6 gint -> gboolean where applicable. The end (ouf!).
zas_
parents: 1437
diff changeset
526 gboolean format_debug_tiff_raw(guchar *data, const guint len,
bc3f5c0432f6 gint -> gboolean where applicable. The end (ouf!).
zas_
parents: 1437
diff changeset
527 guint *image_offset, guint *exif_offset)
101
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
528 {
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
529 ExifByteOrder bo;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
530 gint level;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
531 guint offset;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
532
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
533 if (len < 8) return FALSE;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
534
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
535 /* for debugging, we are more relaxed as to magic header */
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
536 if (memcmp(data, "II", 2) == 0)
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
537 {
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
538 bo = EXIF_BYTE_ORDER_INTEL;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
539 }
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
540 else if (memcmp(data, "MM", 2) == 0)
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
541 {
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
542 bo = EXIF_BYTE_ORDER_MOTOROLA;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
543 }
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
544 else
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
545 {
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
546 return FALSE;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
547 }
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
548
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
549 log_printf("*** debug parsing tiff\n");
101
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
550
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
551 offset = exif_byte_get_int32(data + 4, bo);
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
552 level = 0;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
553 while (offset && level < EXIF_TIFF_MAX_LEVELS)
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
554 {
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
555 offset = format_debug_tiff_table(data, len, offset, bo, 0);
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
556 level++;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
557 }
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
558
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
559 log_printf("*** end\n");
101
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
560
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
561 /* we are debugging, not trying to return any data */
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
562 return FALSE;
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
563 }
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
564 #endif
847e4bc6b54c Tue Nov 7 15:35:59 2006 John Ellis <johne@verizon.net>
gqview
parents: 59
diff changeset
565
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 281
diff changeset
566 #endif
177
0ca3b4c8ffae started exiv2 integration
nadvornik
parents: 138
diff changeset
567 /* not HAVE_EXIV2 */
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 1003
diff changeset
568 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */