6 * Original version 2005 Lars Ellenberg, base on dcraw by David coffin.
8 * This software is released under the GNU General Public License (GNU GPL).
9 * Please read the included file COPYING for more information.
10 * This software comes with no warranty of any kind, use at your own risk!
26 #include "format_fuji.h"
27 #include "format_raw.h"
33 *-----------------------------------------------------------------------------
34 * Raw (RAF) embedded jpeg extraction for Fujifilm
35 *-----------------------------------------------------------------------------
39 gint format_fuji_raw(unsigned char *data, const guint len,
40 guint *image_offset, guint *exif_offset)
46 memcmp(data, "FUJIFILM", 8) != 0)
51 /* offset to jpeg is embedded at bytes 84-87 */
52 io = GUINT32_FROM_BE(*(guint32*)(data + 84));
53 if (io + 4 > len) return FALSE;
55 /* verify jpeg marker */
56 if (memcmp(data + io, "\xff\xd8\xff\xe1", 4) != 0)
61 /* Exif is stored in the jpeg, so use the same offset */
64 if (image_offset) *image_offset = io;
65 if (exif_offset) *exif_offset = eo;
72 *-----------------------------------------------------------------------------
73 * EXIF Makernote for Fujifilm
74 *-----------------------------------------------------------------------------
77 static ExifTextList FujiTagSharpness[] = {
86 static ExifTextList FujiTagWhiteBalance[]= {
90 { 768, "daylight color-fluorescence" },
91 { 769, "daywhite color-fluorescence" },
92 { 770, "white-fluorescence" },
93 { 1024, "incandescent" },
98 static ExifTextList FujiTagColorTone[]= {
105 static ExifTextList FujiTagFlashMode[]= {
109 { 3, "red-eye reduction" },
113 static ExifTextList FujiTagOffOn[]= {
119 static ExifTextList FujiTagFocusMode[]= {
125 static ExifTextList FujiTagPictureMode[]= {
132 { 256, "aperture priority AE" },
133 { 512, "shutter priority AE" },
138 static ExifTextList FujiTagNoYes[]= {
145 static ExifTextList FujiTag[]= {
153 static ExifMarker FujiExifMarkersList[] = {
154 { 0x1000, EXIF_FORMAT_STRING, 8, "Fuji.Quality", "Quality", NULL },
155 { 0x1001, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.Sharpness", "Sharpness", FujiTagSharpness },
156 { 0x1002, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.WhiteBalance", "White balance",FujiTagWhiteBalance },
157 { 0x1003, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.Color", "Color", FujiTagColorTone },
158 { 0x1004, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.Tone", "Tone", FujiTagColorTone },
159 { 0x1010, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.FlashMode", "Flash mode", FujiTagFlashMode },
160 { 0x1011, EXIF_FORMAT_RATIONAL, 1, "Fuji.FlashStrength", "Flash strength", NULL },
161 { 0x1020, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.Macro", "Macro", FujiTagOffOn },
162 { 0x1021, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.FocusMode", "Focus mode", FujiTagFocusMode },
163 { 0x1030, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.SlowSync", "Slow synchro", FujiTagOffOn },
164 { 0x1031, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.PictureMode", "Picture mode", FujiTagPictureMode },
165 { 0x1100, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.ContTake/Bracket",
166 "Continuous / Auto bracket", FujiTagOffOn },
167 { 0x1300, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.BlurWarning", "Blue warning", FujiTagNoYes },
168 { 0x1301, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.FocusWarning", "Focus warning",FujiTagNoYes },
169 { 0x1302, EXIF_FORMAT_SHORT_UNSIGNED, 1, "Fuji.AEWarning", "AE warning", FujiTagNoYes },
175 gint format_fuji_makernote(ExifData *exif, unsigned char *tiff, guint offset,
176 guint size, ExifByteOrder bo)
181 if (offset + 8 + 4 >= size) return FALSE;
183 data = tiff + offset;
185 /* Fuji tag format starts with "FUJIFILM",
186 * followed by 4 bytes indicating offset to IFD directory using Fuji tags,
187 * byte order is always little endian (II).
189 if (memcmp(data, "FUJIFILM", 8) != 0) return FALSE;
191 ifdstart = exif_byte_get_int32(data + 8, EXIF_BYTE_ORDER_INTEL);
192 if (offset + ifdstart >= size) return FALSE;
194 if (exif_parse_IFD_table(exif, tiff + offset, ifdstart, size - offset,
195 EXIF_BYTE_ORDER_INTEL, 0, FujiExifMarkersList) != 0)