86
86
unsigned char **buf, unsigned int *buf_size)
88
88
ExifMnoteDataOlympus *n = (ExifMnoteDataOlympus *) ne;
89
unsigned int i, o, s, doff, base = 0, o2 = 6;
89
unsigned int i, o, s, doff, base = 0, o2 = 6 + 2;
92
92
if (!n || !buf || !buf_size) return;
95
95
* Allocate enough memory for all entries and the number of entries.
97
97
*buf_size = 6 + 2 + 2 + n->count * 12;
99
98
switch (n->version) {
101
100
*buf = exif_mem_alloc (ne->mem, *buf_size);
102
101
if (!*buf) return;
104
103
/* Write the header and the number of entries. */
105
104
strcpy ((char *)*buf, "OLYMP");
105
exif_set_short (*buf + 6, n->order, (ExifShort) 1);
106
106
datao = n->offset;
109
*buf_size += 8-6 + 4;
110
*buf = exif_mem_alloc (ne->mem, *buf_size);
113
/* Write the header and the number of entries. */
114
strcpy ((char *)*buf, "OLYMPUS");
115
exif_set_short (*buf + 8, n->order, (ExifShort) (
116
(n->order == EXIF_BYTE_ORDER_INTEL) ?
119
exif_set_short (*buf + 10, n->order, (ExifShort) 3);
109
123
base = MNOTE_NIKON1_TAG_BASE;
125
/* v1 has offsets based to main IFD, not makernote IFD */
126
datao += n->offset + 10;
111
127
/* subtract the size here, so the increment in the next case will not harm us */
113
129
/* Fall through */
132
*buf_size += 4; /* Next IFD pointer */
116
133
*buf = exif_mem_alloc (ne->mem, *buf_size);
117
134
if (!*buf) return;
120
137
strcpy ((char *)*buf, "Nikon");
121
138
(*buf)[6] = n->version;
124
140
if (n->version == nikonV2) {
125
141
exif_set_short (*buf + 10, n->order, (ExifShort) (
126
142
(n->order == EXIF_BYTE_ORDER_INTEL) ?
130
146
exif_set_long (*buf + 14, n->order, (ExifShort) 8);
150
/* Reset next IFD pointer */
151
exif_set_long (*buf + o2 + 2 + n->count * 12, n->order, 0);
203
221
if (buf_size - n->offset < 22) return;
204
if (!memcmp (buf + o2, "OLYMP", 5)) {
222
if (!memcmp (buf + o2, "OLYMP", 6)) {
205
223
exif_log (en->log, EXIF_LOG_CODE_DEBUG, "ExifMnoteDataOlympus",
206
"Parsing Olympus maker note...");
224
"Parsing Olympus maker note v1...");
208
226
/* The number of entries is at position 8. */
209
n->version = olympus;
227
n->version = olympusV1;
228
if (buf[o2 + 6] == 1)
229
n->order = EXIF_BYTE_ORDER_INTEL;
230
else if (buf[o2 + 6 + 1] == 1)
231
n->order = EXIF_BYTE_ORDER_MOTOROLA;
234
} else if (!memcmp (buf + o2, "OLYMPUS", 8)) {
235
/* Olympus S760, S770 */
238
exif_log (en->log, EXIF_LOG_CODE_DEBUG, "ExifMnoteDataOlympus",
239
"Parsing Olympus maker note v2 (0x%02x, %02x, %02x, %02x)...",
240
buf[o2], buf[o2 + 1], buf[o2 + 2], buf[o2 + 3]);
242
if ((buf[o2] == 'I') && (buf[o2 + 1] == 'I'))
243
n->order = EXIF_BYTE_ORDER_INTEL;
244
else if ((buf[o2] == 'M') && (buf[o2 + 1] == 'M'))
245
n->order = EXIF_BYTE_ORDER_MOTOROLA;
247
/* The number of entries is at position 8+4. */
248
n->version = olympusV2;
212
251
} else if (!memcmp (buf + o2, "Nikon", 6)) {