4 * Copyright (C) 2008 - 2012 The Geeqie Team
7 * Original version 2005 Lars Ellenberg, base on dcraw by David coffin.
9 * This software is released under the GNU General Public License (GNU GPL).
10 * Please read the included file COPYING for more information.
11 * This software comes with no warranty of any kind, use at your own risk!
29 #include "format_fuji.h"
30 #include "format_raw.h"
36 *-----------------------------------------------------------------------------
37 * Raw (RAF) embedded jpeg extraction for Fujifilm
38 *-----------------------------------------------------------------------------
42 gboolean format_fuji_raw(guchar *data, const guint len,
43 guint *image_offset, guint *exif_offset)
49 memcmp(data, "FUJIFILM", 8) != 0)
54 /* offset to jpeg is embedded at bytes 84-87 */
55 io = exif_byte_get_int32(data + 84, EXIF_BYTE_ORDER_MOTOROLA);
56 if (io + 4 > len) return FALSE;
58 /* verify jpeg marker */
59 if (memcmp(data + io, "\xff\xd8\xff\xe1", 4) != 0)
64 /* Exif is stored in the jpeg, so use the same offset */
67 if (image_offset) *image_offset = io;
68 if (exif_offset) *exif_offset = eo;
75 *-----------------------------------------------------------------------------
76 * EXIF Makernote for Fujifilm
77 *-----------------------------------------------------------------------------
80 static ExifTextList FujiTagSharpness[] = {
89 static ExifTextList FujiTagWhiteBalance[]= {
93 { 768, "daylight color-fluorescence" },
94 { 769, "daywhite color-fluorescence" },
95 { 770, "white-fluorescence" },
96 { 1024, "incandescent" },
101 static ExifTextList FujiTagColorTone[]= {
108 static ExifTextList FujiTagFlashMode[]= {
112 { 3, "red-eye reduction" },
116 static ExifTextList FujiTagOffOn[]= {
122 static ExifTextList FujiTagFocusMode[]= {
128 static ExifTextList FujiTagPictureMode[]= {
135 { 256, "aperture priority AE" },
136 { 512, "shutter priority AE" },
141 static ExifTextList FujiTagNoYes[]= {
148 static ExifMarker FujiExifMarkersList[] = {
149 { 0x1000, EXIF_FORMAT_STRING, 8, "Fuji.Quality", "Quality", NULL },
150 { 0x1001, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.Sharpness", "Sharpness", FujiTagSharpness },
151 { 0x1002, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.WhiteBalance", "White balance",FujiTagWhiteBalance },
152 { 0x1003, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.Color", "Color", FujiTagColorTone },
153 { 0x1004, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.Tone", "Tone", FujiTagColorTone },
154 { 0x1010, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.FlashMode", "Flash mode", FujiTagFlashMode },
155 { 0x1011, EXIF_FORMAT_RATIONAL, 1, "Fuji.FlashStrength", "Flash strength", NULL },
156 { 0x1020, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.Macro", "Macro", FujiTagOffOn },
157 { 0x1021, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.FocusMode", "Focus mode", FujiTagFocusMode },
158 { 0x1030, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.SlowSync", "Slow synchro", FujiTagOffOn },
159 { 0x1031, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.PictureMode", "Picture mode", FujiTagPictureMode },
160 { 0x1100, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.ContTake/Bracket",
161 "Continuous / Auto bracket", FujiTagOffOn },
162 { 0x1300, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.BlurWarning", "Blue warning", FujiTagNoYes },
163 { 0x1301, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.FocusWarning", "Focus warning",FujiTagNoYes },
164 { 0x1302, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.AEWarning", "AE warning", FujiTagNoYes },
170 gboolean format_fuji_makernote(ExifData *exif, guchar *tiff, guint offset,
171 guint size, ExifByteOrder bo)
176 if (offset + 8 + 4 >= size) return FALSE;
178 data = tiff + offset;
180 /* Fuji tag format starts with "FUJIFILM",
181 * followed by 4 bytes indicating offset to IFD directory using Fuji tags,
182 * byte order is always little endian (II).
184 if (memcmp(data, "FUJIFILM", 8) != 0) return FALSE;
186 ifdstart = exif_byte_get_int32(data + 8, EXIF_BYTE_ORDER_INTEL);
187 if (offset + ifdstart >= size) return FALSE;
189 if (exif_parse_IFD_table(exif, tiff + offset, ifdstart, size - offset,
190 EXIF_BYTE_ORDER_INTEL, 0, FujiExifMarkersList) != 0)
200 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */