27 #include <sys/types.h>
32 #undef JPEG_MARKER_DCT
33 #define JPEG_MARKER_DCT 0xc0
34 #undef JPEG_MARKER_DHT
35 #define JPEG_MARKER_DHT 0xc4
36 #undef JPEG_MARKER_SOI
37 #define JPEG_MARKER_SOI 0xd8
38 #undef JPEG_MARKER_DQT
39 #define JPEG_MARKER_DQT 0xdb
40 #undef JPEG_MARKER_APP0
41 #define JPEG_MARKER_APP0 0xe0
42 #undef JPEG_MARKER_APP1
43 #define JPEG_MARKER_APP1 0xe1
44 #undef JPEG_MARKER_APP2
45 #define JPEG_MARKER_APP2 0xe2
46 #undef JPEG_MARKER_APP4
47 #define JPEG_MARKER_APP4 0xe4
48 #undef JPEG_MARKER_APP5
49 #define JPEG_MARKER_APP5 0xe5
50 #undef JPEG_MARKER_APP11
51 #define JPEG_MARKER_APP11 0xeb
52 #undef JPEG_MARKER_APP13
53 #define JPEG_MARKER_APP13 0xed
54 #undef JPEG_MARKER_APP14
55 #define JPEG_MARKER_APP14 0xee
56 #undef JPEG_MARKER_COM
57 #define JPEG_MARKER_COM 0xfe
98 static const unsigned char ExifHeader[] = {0x45, 0x78, 0x69, 0x66, 0x00, 0x00};
121 unsigned char data[1024];
126 f = fopen (path,
"rb");
129 _(
"The file '%s' could not be opened."), path);
133 size = fread (data, 1,
sizeof (data), f);
168 if (!eld || (len && !buf))
171 switch (eld->
state) {
175 if (eld->
size > len) {
201 "Scanning %i byte(s) of data...", len);
207 i =
MIN (len,
sizeof (eld->
b) - eld->
b_len);
209 memcpy (&eld->
b[eld->
b_len], buf, i);
211 if (eld->
b_len < sizeof (eld->
b))
221 if (!memcmp (eld->
b,
"FUJIFILM", 8)) {
239 for (i = 0; i <
sizeof (eld->
b); i++) {
240 switch (eld->
state) {
243 sizeof (eld->
b) - i))
263 eld->
size |= (
unsigned int)eld->
b[i] << 24;
267 eld->
size |= (
unsigned int)eld->
b[i] << 16;
271 eld->
size |= (
unsigned int)eld->
b[i] << 8;
275 eld->
size |= eld->
b[i] << 0;
288 if (eld->
size < 86) {
334 "ExifLoader",
_(
"The data supplied "
335 "does not seem to contain "
443 unsigned int *buf_size)
445 const unsigned char* b = NULL;
451 "Loader format unknown");
void exif_data_load_data(ExifData *data, const unsigned char *d_orig, unsigned int ds)
Load the ExifData structure from the raw JPEG or EXIF data in the given memory buffer.
ExifData * exif_data_new_mem(ExifMem *mem)
Allocate a new ExifData using the given memory allocator.
void exif_data_log(ExifData *data, ExifLog *log)
Set the log message object for all IFDs.
void exif_loader_log(ExifLoader *loader, ExifLog *log)
Set the log message object used by this ExifLoader.
void exif_loader_reset(ExifLoader *loader)
Free any data previously loaded and reset the ExifLoader to its newly-initialized state.
ExifLoader * exif_loader_new(void)
Allocate a new ExifLoader.
static void exif_loader_free(ExifLoader *loader)
@ EL_DATA_FORMAT_FUJI_RAW
#define JPEG_MARKER_APP13
static const unsigned char ExifHeader[]
Magic number for EXIF header.
void exif_loader_unref(ExifLoader *loader)
Decrease the refcount of the ExifLoader.
#define JPEG_MARKER_APP14
#define JPEG_MARKER_APP11
ExifLoader * exif_loader_new_mem(ExifMem *mem)
Allocate a new ExifLoader using the specified memory allocator.
ExifData * exif_loader_get_data(ExifLoader *loader)
Create an ExifData from the data in the loader.
unsigned char exif_loader_write(ExifLoader *eld, unsigned char *buf, unsigned int len)
Load a buffer into the ExifLoader from a memory buffer.
void exif_loader_ref(ExifLoader *loader)
Increase the refcount of the ExifLoader.
static unsigned int exif_loader_copy(ExifLoader *eld, unsigned char *buf, unsigned int len)
void exif_loader_get_buf(ExifLoader *loader, const unsigned char **buf, unsigned int *buf_size)
Return the raw data read by the loader.
void exif_loader_write_file(ExifLoader *l, const char *path)
Load a file into the given ExifLoader from the filesystem.
static void * exif_loader_alloc(ExifLoader *l, unsigned int i)
Defines the ExifLoader type.
void exif_log(ExifLog *log, ExifLogCode code, const char *domain, const char *format,...)
void exif_log_unref(ExifLog *log)
void exif_log_ref(ExifLog *log)
@ EXIF_LOG_CODE_CORRUPT_DATA
#define EXIF_LOG_NO_MEMORY(l, d, s)
void exif_mem_free(ExifMem *mem, void *d)
void exif_mem_unref(ExifMem *mem)
Unrefcount an ExifMem.
ExifMem * exif_mem_new_default(void)
Create a new ExifMem with default values for your convenience.
void * exif_mem_alloc(ExifMem *mem, ExifLong ds)
void exif_mem_ref(ExifMem *mem)
Refcount an ExifMem.
EXIF data manipulation functions and types.
Represents the entire EXIF data found in an image.
ExifLoaderDataFormat data_format
unsigned char b[12]
Small buffer used for detection of format.
unsigned char b_len
Number of bytes in the small buffer b.