38 #define CHECKOVERFLOW(offset,datasize,structsize) (( offset >= datasize) || (structsize > datasize) || (offset > datasize - structsize ))
42 unsigned int buf_size);
54 for (i = 0; i < n->
count; i++)
78 if (!d || !val)
return NULL;
79 if (i > n->
count -1)
return NULL;
100 unsigned char **buf,
unsigned int *buf_size)
103 size_t i, o, s, doff, base = 0, o2 = 6 + 2;
108 if (!n || !buf || !buf_size)
return;
113 *buf_size = 6 + 2 + 2 + n->
count * 12;
132 *buf_size += 8-6 + 4;
140 strcpy ((
char *)*buf,
"OLYMPUS");
170 strcpy ((
char *)*buf,
"Nikon");
195 for (i = 0; i < n->
count; i++) {
232 memset (*buf + doff, 0, s);
239 const unsigned char *buf,
unsigned int buf_size)
243 size_t i, tcount, o, o2, datao = 6, base = 0;
245 if (!n || !buf || !buf_size) {
247 "ExifMnoteDataOlympus",
"Short MakerNote");
253 "ExifMnoteDataOlympus",
"Short MakerNote");
284 "Parsing Olympus/Sanyo/Epson maker note v1...");
287 if (buf[o2 + 6] == 1)
289 else if (buf[o2 + 6 + 1] == 1)
293 if ((!(c & 0xFF)) && (c > 0x500)) {
308 "Parsing Olympus maker note v2 (0x%02x, %02x, %02x, %02x)...",
309 buf[o2 + 0], buf[o2 + 1], buf[o2 + 2], buf[o2 + 3]);
311 if ((buf[o2] ==
'I') && (buf[o2 + 1] ==
'I'))
313 else if ((buf[o2] ==
'M') && (buf[o2 + 1] ==
'M'))
323 "Parsing Nikon maker note v1 (0x%02x, %02x, %02x, "
325 buf[o2 + 0], buf[o2 + 1], buf[o2 + 2], buf[o2 + 3]);
336 if ((!(c & 0xFF)) && (c > 0x500)) {
349 "Parsing Nikon maker note v2 (0x%02x, %02x, %02x, "
350 "%02x, %02x, %02x, %02x, %02x)...",
351 buf[o2 + 0], buf[o2 + 1], buf[o2 + 2], buf[o2 + 3],
352 buf[o2 + 4], buf[o2 + 5], buf[o2 + 6], buf[o2 + 7]);
368 if (!strncmp ((
char *)&buf[o2],
"II", 2))
370 else if (!strncmp ((
char *)&buf[o2],
"MM", 2))
374 "ExifMnoteDataOlympus",
"Unknown "
375 "byte order '%c%c'", buf[o2],
390 "Parsing Nikon maker note v0 (0x%02x, %02x, %02x, "
391 "%02x, %02x, %02x, %02x, %02x)...",
392 buf[o2 + 0], buf[o2 + 1], buf[o2 + 2], buf[o2 + 3],
393 buf[o2 + 4], buf[o2 + 5], buf[o2 + 6], buf[o2 + 7]);
400 "Unknown Olympus variant %i.", n->
version);
407 "ExifMnoteOlympus",
"Short MakerNote");
434 for (i = c, o = o2; i; --i, o += 12) {
439 "ExifMnoteOlympus",
"Short MakerNote");
449 "Loading entry 0x%x ('%s')...", n->
entries[tcount].
tag,
474 size_t dataofs = o + 8;
478 #ifdef EXIF_OVERCOME_SANYO_OFFSET_BUG
486 dataofs -= datao + 6;
489 "Inconsistent thumbnail tag offset; attempting to recover");
496 "Tag data past end of buffer (%u > %u)",
497 (
unsigned)(dataofs + s), buf_size);
506 memcpy (n->
entries[tcount].
data, buf + dataofs, s);
528 if (note->
count <= n)
return 0;
538 if (i >= n->
count)
return NULL;
548 if (i >= n->
count)
return NULL;
558 if (i >= n->
count)
return NULL;
573 for (i = 0; i < n->
count; i++) {
590 unsigned int buf_size)
595 if (!memcmp (buf,
"OLYMPUS", 8))
597 else if (!memcmp (buf,
"OLYMP", 6))
599 else if (!memcmp (buf,
"SANYO", 6))
601 else if (!memcmp (buf,
"EPSON", 6))
603 else if (!memcmp (buf,
"Nikon", 6)) {
613 if ((buf_size >= 2) && (buf[0] == 0x00) && (buf[1] == 0x1b)) {
633 if (v && (!strncmp (v,
"Nikon",
sizeof(value)) ||
634 !strncmp (v,
"NIKON",
sizeof(value)) ))
651 if (!mem)
return NULL;
ExifByteOrder
Which byte order to use.
@ EXIF_BYTE_ORDER_INTEL
Little-endian byte order.
@ EXIF_BYTE_ORDER_MOTOROLA
Big-endian byte order.
Defines the ExifData type and the associated functions.
#define exif_data_get_entry(d, t)
Return an ExifEntry for the given tag if found in any IFD.
const char * exif_entry_get_value(ExifEntry *e, char *val, unsigned int maxlen)
Return a localized textual representation of the value of the EXIF entry.
void exif_log(ExifLog *log, ExifLogCode code, const char *domain, const char *format,...)
@ EXIF_LOG_CODE_CORRUPT_DATA
#define EXIF_LOG_NO_MEMORY(l, d, s)
void * exif_mem_realloc(ExifMem *mem, void *d, ExifLong ds)
void exif_mem_free(ExifMem *mem, void *d)
void * exif_mem_alloc(ExifMem *mem, ExifLong ds)
static const char * exif_mnote_data_olympus_get_name(ExifMnoteData *d, unsigned int i)
static void exif_mnote_data_olympus_set_offset(ExifMnoteData *n, unsigned int o)
static unsigned int exif_mnote_data_olympus_count(ExifMnoteData *n)
static enum OlympusVersion exif_mnote_data_olympus_identify_variant(const unsigned char *buf, unsigned int buf_size)
static void exif_mnote_data_olympus_free(ExifMnoteData *n)
static void exif_mnote_data_olympus_load(ExifMnoteData *en, const unsigned char *buf, unsigned int buf_size)
static const char * exif_mnote_data_olympus_get_title(ExifMnoteData *d, unsigned int i)
ExifMnoteData * exif_mnote_data_olympus_new(ExifMem *mem)
static void exif_mnote_data_olympus_save(ExifMnoteData *ne, unsigned char **buf, unsigned int *buf_size)
save the MnoteData from ne to buf
static void exif_mnote_data_olympus_set_byte_order(ExifMnoteData *d, ExifByteOrder o)
static char * exif_mnote_data_olympus_get_value(ExifMnoteData *d, unsigned int i, char *val, unsigned int maxlen)
static void exif_mnote_data_olympus_clear(ExifMnoteDataOlympus *n)
int exif_mnote_data_olympus_identify(const ExifData *ed, const ExifEntry *e)
Detect if MakerNote is recognized as one handled by the Olympus module.
static unsigned int exif_mnote_data_olympus_get_id(ExifMnoteData *d, unsigned int n)
static const char * exif_mnote_data_olympus_get_description(ExifMnoteData *d, unsigned int i)
#define CHECKOVERFLOW(offset, datasize, structsize)
void exif_mnote_data_construct(ExifMnoteData *, ExifMem *mem)
ExifLong exif_get_long(const unsigned char *buf, ExifByteOrder order)
Retrieve an ExifLong value from memory.
ExifShort exif_get_short(const unsigned char *buf, ExifByteOrder order)
Retrieve an ExifShort value from memory.
void exif_array_set_byte_order(ExifFormat f, unsigned char *b, unsigned int n, ExifByteOrder o_orig, ExifByteOrder o_new)
void exif_set_long(unsigned char *b, ExifByteOrder order, ExifLong value)
Store an ExifLong value into memory in EXIF format.
void exif_set_short(unsigned char *b, ExifByteOrder order, ExifShort value)
Store an ExifShort value into memory in EXIF format.
EXIF data manipulation functions and types.
uint16_t ExifShort
EXIF Unsigned Short data type.
char * mnote_olympus_entry_get_value(MnoteOlympusEntry *entry, char *v, unsigned int maxlen)
const char * mnote_olympus_tag_get_title(MnoteOlympusTag t)
Return a textual title of the given tag within the Olympus-style MakerNote.
const char * mnote_olympus_tag_get_name(MnoteOlympusTag t)
Return a textual name of the given tag within the Olympus-style MakerNote.
const char * mnote_olympus_tag_get_description(MnoteOlympusTag t)
Return a verbose textual description of the given tag within the Olympus-style MakerNote.
Represents the entire EXIF data found in an image.
Data found in one EXIF tag.
unsigned char * data
Pointer to the raw EXIF data for this entry.
unsigned int size
Number of bytes in the buffer at data.
const char *(* get_description)(ExifMnoteData *, unsigned int)
void(* load)(ExifMnoteData *, const unsigned char *, unsigned int)
const char *(* get_name)(ExifMnoteData *, unsigned int)
const char *(* get_title)(ExifMnoteData *, unsigned int)
char *(* get_value)(ExifMnoteData *, unsigned int, char *val, unsigned int maxlen)
unsigned int(* get_id)(ExifMnoteData *, unsigned int)
void(* save)(ExifMnoteData *, unsigned char **, unsigned int *)
unsigned int(* count)(ExifMnoteData *)
void(* set_offset)(ExifMnoteData *, unsigned int)
void(* set_byte_order)(ExifMnoteData *, ExifByteOrder)
void(* free)(ExifMnoteData *)
enum OlympusVersion version
MnoteOlympusEntry * entries
ExifMnoteDataMethods methods