Deduplicate cell_renderer_height_override()
[geeqie.git] / src / exif-int.h
1 /*
2  * Copyright (C) 2006 John Ellis
3  * Copyright (C) 2008 - 2016 The Geeqie Team
4  *
5  * Authors: Eric Swalens, Quy Tonthat, John Ellis
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #ifndef __EXIF_INT_H
23 #define __EXIF_INT_H
24
25 #include <cstdio>
26
27 #include "exif.h"
28
29 /*
30  *-----------------------------------------------------------------------------
31  * Tag formats
32  *-----------------------------------------------------------------------------
33  */
34
35 enum ExifByteOrder {
36         EXIF_BYTE_ORDER_INTEL,
37         EXIF_BYTE_ORDER_MOTOROLA
38 };
39
40 struct ExifFormatAttrib
41 {
42         ExifFormatType type;
43         guint size;
44         const gchar *short_name;
45         const gchar *description;
46 };
47
48 extern ExifFormatAttrib ExifFormatList[]; /**< the list of known tag data formats */
49
50
51 /*
52  *-----------------------------------------------------------------------------
53  * Data storage
54  *-----------------------------------------------------------------------------
55  */
56
57 struct ExifData
58 {
59         gchar *path;
60         GList *items;   /**< list of (ExifItem *) */
61         GList *current; /**< for exif_get_next_item */
62 };
63
64 struct ExifTextList
65 {
66         gint value;
67         const gchar *description;
68 };
69
70 struct ExifMarker
71 {
72         guint           tag;
73         ExifFormatType  format;
74         gint            components;
75         const gchar             *key;
76         const gchar             *description;
77         ExifTextList    *list;
78 };
79
80 struct ExifItem
81 {
82         ExifFormatType format;
83         guint tag;
84         const ExifMarker *marker;
85         guint elements;
86         gpointer data;
87         guint data_len;
88 };
89
90 #define EXIF_MARKER_LIST_END { 0x0000, EXIF_FORMAT_UNKNOWN, 0, NULL, NULL, NULL }
91
92 #define EXIF_TEXT_LIST_END { -1, NULL }
93
94
95
96
97 /*
98  *-----------------------------------------------------------------------------
99  * Data
100  *-----------------------------------------------------------------------------
101  */
102
103
104
105 extern ExifMarker ExifKnownMarkersList[]; /**< the known exif tags list */
106
107 extern ExifMarker ExifUnknownMarkersList[]; /**< the unknown tags utilize this generic list */
108
109 extern ExifFormattedText ExifFormattedList[]; /**< the list of specially formatted keys, for human readable output */
110
111
112 /*
113  *-----------------------------------------------------------------------------
114  * functions
115  *-----------------------------------------------------------------------------
116  */
117
118 /**
119  * @headerfile exif_write_data_list
120  * usually for debugging to stdout
121  */
122 void exif_write_data_list(ExifData *exif, FILE *f, gint human_readable_list);
123
124
125
126 /* These funcs for use by makernote/tiff parsers only */
127
128 #define EXIF_TIFF_MAX_LEVELS 4
129
130 #define EXIF_TIFD_OFFSET_TAG 0
131 #define EXIF_TIFD_OFFSET_FORMAT 2
132 #define EXIF_TIFD_OFFSET_COUNT 4
133 #define EXIF_TIFD_OFFSET_DATA 8
134 #define EXIF_TIFD_SIZE 12
135
136
137 guint16 exif_byte_get_int16(guchar *f, ExifByteOrder bo);
138 guint32 exif_byte_get_int32(guchar *f, ExifByteOrder bo);
139 void exif_byte_put_int16(guchar *f, guint16 n, ExifByteOrder bo);
140 void exif_byte_put_int32(guchar *f, guint32 n, ExifByteOrder bo);
141
142 ExifItem *exif_item_new(ExifFormatType format, guint tag,
143                         guint elements, const ExifMarker *marker);
144 void exif_item_copy_data(ExifItem *item, gpointer src, guint len,
145                          ExifFormatType src_format, ExifByteOrder bo);
146
147 gint exif_parse_IFD_table(ExifData *exif,
148                           guchar *tiff, guint offset,
149                           guint size, ExifByteOrder bo,
150                           gint level,
151                           const ExifMarker *list);
152
153 gint exif_tiff_directory_offset(guchar *data, guint len,
154                                 guint *offset, ExifByteOrder *bo);
155 gint exif_tiff_parse(ExifData *exif, guchar *tiff, guint size, ExifMarker *list);
156
157 gchar *exif_text_list_find_value(ExifTextList *list, guint value);
158
159 #endif
160 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */