40#define CHECKOVERFLOW(offset,datasize,structsize) (( (offset) >= (datasize)) || ((structsize) > (datasize)) || ((offset) > (datasize) - (structsize) ))
44 unsigned int buf_size);
56 for (i = 0; i < n->
count; i++)
80 if (!d || !val)
return NULL;
81 if (i >= n->
count)
return NULL;
102 unsigned char **buf,
unsigned int *buf_size)
105 size_t i, o, s, doff, base = 0, o2 = 6 + 2;
110 if (!n || !buf || !buf_size)
return;
115 *buf_size = 6 + 2 + 2 + n->
count * 12;
134 *buf_size += 8-6 + 4;
142 strcpy ((
char *)*buf,
"OLYMPUS");
172 strcpy ((
char *)*buf,
"Nikon");
173 (*buf)[6] = (
unsigned char)n->
version;
197 for (i = 0; i < n->
count; i++) {
234 memset (*buf + doff, 0, s);
241 const unsigned char *buf,
unsigned int buf_size)
245 size_t i, tcount, o, o2, datao = 6, base = 0;
249 if (!buf || !buf_size) {
251 "ExifMnoteDataOlympus",
"Short MakerNote");
257 "ExifMnoteDataOlympus",
"Short MakerNote");
288 "Parsing Olympus/Sanyo/Epson maker note v1...");
291 if (buf[o2 + 6] == 1)
293 else if (buf[o2 + 6 + 1] == 1)
297 if ((!(c & 0xFF)) && (c > 0x500)) {
312 "Parsing Olympus maker note v2 (0x%02x, %02x, %02x, %02x)...",
313 buf[o2 + 0], buf[o2 + 1], buf[o2 + 2], buf[o2 + 3]);
315 if ((buf[o2] ==
'I') && (buf[o2 + 1] ==
'I'))
317 else if ((buf[o2] ==
'M') && (buf[o2 + 1] ==
'M'))
327 "Parsing Nikon maker note v1 (0x%02x, %02x, %02x, "
329 buf[o2 + 0], buf[o2 + 1], buf[o2 + 2], buf[o2 + 3]);
340 if ((!(c & 0xFF)) && (c > 0x500)) {
353 "Parsing Nikon maker note v2 (0x%02x, %02x, %02x, "
354 "%02x, %02x, %02x, %02x, %02x)...",
355 buf[o2 + 0], buf[o2 + 1], buf[o2 + 2], buf[o2 + 3],
356 buf[o2 + 4], buf[o2 + 5], buf[o2 + 6], buf[o2 + 7]);
372 if (!strncmp ((
char *)&buf[o2],
"II", 2))
374 else if (!strncmp ((
char *)&buf[o2],
"MM", 2))
378 "ExifMnoteDataOlympus",
"Unknown "
379 "byte order '%c%c'", buf[o2],
395 "Parsing Nikon maker note v0 (0x%02x, %02x, %02x, "
396 "%02x, %02x, %02x, %02x, %02x)...",
397 buf[o2 + 0], buf[o2 + 1], buf[o2 + 2], buf[o2 + 3],
398 buf[o2 + 4], buf[o2 + 5], buf[o2 + 6], buf[o2 + 7]);
405 "Unknown Olympus variant %i.", n->
version);
412 "ExifMnoteOlympus",
"Short MakerNote");
439 for (i = c, o = o2; i; --i, o += 12) {
444 "ExifMnoteOlympus",
"Short MakerNote");
454 "Loading entry 0x%x ('%s')...", n->
entries[tcount].
tag,
479 size_t dataofs = o + 8;
483#ifdef EXIF_OVERCOME_SANYO_OFFSET_BUG
491 dataofs -= datao + 6;
494 "Inconsistent thumbnail tag offset; attempting to recover");
501 "Tag data past end of buffer (%u > %u)",
502 (
unsigned)(dataofs + s), buf_size);
511 memcpy (n->
entries[tcount].
data, buf + dataofs, s);
533 if (note->
count <= n)
return 0;
543 if (i >= n->
count)
return NULL;
553 if (i >= n->
count)
return NULL;
563 if (i >= n->
count)
return NULL;
578 for (i = 0; i < n->
count; i++) {
595 unsigned int buf_size)
600 if (!memcmp (buf,
"OLYMPUS", 8))
602 else if (!memcmp (buf,
"OLYMP", 6))
604 else if (!memcmp (buf,
"SANYO", 6))
606 else if (!memcmp (buf,
"EPSON", 6))
608 else if (!memcmp (buf,
"Nikon", 6)) {
618 if ((buf_size >= 2) && (buf[0] == 0x00) && (buf[1] == 0x1b)) {
638 if (v && (!strncmp (v,
"Nikon",
sizeof(value)) ||
639 !strncmp (v,
"NIKON",
sizeof(value)) ))
656 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_free(ExifMem *mem, void *d)
void * exif_mem_alloc(ExifMem *mem, ExifLong ds)
void * exif_mem_realloc(ExifMem *mem, void *d, ExifLong ds)
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_description(ExifMnoteData *d, unsigned int i)
static char * exif_mnote_data_olympus_get_value(ExifMnoteData *d, unsigned int i, char *val, unsigned int maxlen)
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 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_title(ExifMnoteData *d, unsigned int i)
#define CHECKOVERFLOW(offset, datasize, structsize)
static const char * exif_mnote_data_olympus_get_name(ExifMnoteData *d, unsigned int i)
ExifMnoteData * exif_mnote_data_olympus_new(ExifMem *mem)
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_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.
const char * mnote_olympus_tag_get_title(MnoteOlympusTag t)
Return a textual title 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_name)(ExifMnoteData *, unsigned int)
const char *(* get_description)(ExifMnoteData *, unsigned int)
void(* load)(ExifMnoteData *, const unsigned char *, 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)
const char *(* get_title)(ExifMnoteData *, unsigned int)
void(* set_byte_order)(ExifMnoteData *, ExifByteOrder)
void(* free)(ExifMnoteData *)
enum OlympusVersion version
MnoteOlympusEntry * entries
ExifMnoteDataMethods methods