From: Jef D. <jef...@ho...> - 2006-09-06 13:16:03
|
Many makernote tags are already documented by the 'exiftool' project [1], but are not in the libexif library. I'm working on adding those canon makernotes to the libexif library. I already figured out how to add entries for already existing tags, but I'm having trouble adding new tags. In mnote-canon-tag.h, I define the new tag: MNOTE_CANON_TAG_FOCAL_LENGTH = 0x2 And in mnote-canon-tag.c, I add the necessary human readable names to both tables. And in mnote-canon-entry.c, I add a section to the function mnote_canon_entry_get_value. I copied more or less the code from section MNOTE_CANON_TAG_SETTINGS_1 as a starting point: case MNOTE_CANON_TAG_FOCAL_LENGTH: CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); n = exif_get_short (data, entry->order) / 2; if (t >= n) return NULL; CC (entry->components, n, val, maxlen); vs = exif_get_short (entry->data + 2 + t * 2, entry->order); snprintf (buf, sizeof (buf), "0x%04x", vs); strncpy (val, buf, maxlen - strlen (val)); break; But when I run the exif commandline utility, an error is reported for the new tag: Focal type |Invalid number of components (4, expected 1). What am I doing wrong here? [1] http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Canon.html |
From: Jan P. <pa...@pi...> - 2006-09-06 13:26:06
|
Jef, this message is printed by the CC macro. It checks whether 1st & 2nd arguments are equal. apparently entry->components is 4, but n is only 1. Hope this helps.. -- Jan > case MNOTE_CANON_TAG_FOCAL_LENGTH: > CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); > n = exif_get_short (data, entry->order) / 2; > if (t >= n) return NULL; > CC (entry->components, n, val, maxlen); > vs = exif_get_short (entry->data + 2 + t * 2, entry->order); > snprintf (buf, sizeof (buf), "0x%04x", vs); > strncpy (val, buf, maxlen - strlen (val)); > break; > > But when I run the exif commandline utility, an error is reported for > the new tag: > > Focal type |Invalid number of components (4, expected 1). > > What am I doing wrong here? > > [1] http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Canon.html |
From: Jef D. <jef...@ho...> - 2006-09-06 13:38:18
|
Jan Patera wrote: >> case MNOTE_CANON_TAG_FOCAL_LENGTH: >> CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); >> n = exif_get_short (data, entry->order) / 2; >> if (t >= n) return NULL; >> CC (entry->components, n, val, maxlen); >> vs = exif_get_short (entry->data + 2 + t * 2, entry->order); >> snprintf (buf, sizeof (buf), "0x%04x", vs); >> strncpy (val, buf, maxlen - strlen (val)); >> break; >> >> But when I run the exif commandline utility, an error is reported for >> the new tag: >> >> Focal type |Invalid number of components (4, expected 1). >> >> What am I doing wrong here? > > > this message is printed by the CC macro. It checks whether > 1st & 2nd arguments are equal. apparently entry->components is 4, > but n is only 1. I knew it was reported by the CC macro, but I don't understand why it is happening. It is exactly the same code as is used for MNOTE_CANON_TAG_SETTINGS_1 (which also has multiple components), but no error there! Probably I forgot to add some code somewhere else, but I don't see it. |
From: Marcus M. <mei...@su...> - 2006-09-06 13:57:30
|
On Wed, Sep 06, 2006 at 03:39:30PM +0200, Jef Driesen wrote: > Jan Patera wrote: > >> case MNOTE_CANON_TAG_FOCAL_LENGTH: > >> CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); > >> n = exif_get_short (data, entry->order) / 2; > >> if (t >= n) return NULL; > >> CC (entry->components, n, val, maxlen); > >> vs = exif_get_short (entry->data + 2 + t * 2, entry->order); > >> snprintf (buf, sizeof (buf), "0x%04x", vs); > >> strncpy (val, buf, maxlen - strlen (val)); > >> break; > >> > >> But when I run the exif commandline utility, an error is reported for > >> the new tag: > >> > >> Focal type |Invalid number of components (4, expected 1). > >> > >> What am I doing wrong here? > > > > > > this message is printed by the CC macro. It checks whether > > 1st & 2nd arguments are equal. apparently entry->components is 4, > > but n is only 1. > > I knew it was reported by the CC macro, but I don't understand why it is > happening. It is exactly the same code as is used for > MNOTE_CANON_TAG_SETTINGS_1 (which also has multiple components), but no > error there! Probably I forgot to add some code somewhere else, but I > don't see it. Just a wild guess: Did you adjust mnote_canon_entry_count_values() too? Ciao, Marcus |
From: Jan P. <pa...@pi...> - 2006-09-06 14:56:56
|
Jef, I inspected http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Canon.html#FocalLength and here is what I have found out: 1) MNOTE_CANON_TAG_FOCAL_LENGTH data is expected to be of the EXIF_FORMAT_SHORT format and to have 4 items 2) the 1st value is FocalType, and not size of any kind. Thus the correct sanity checks & code are: CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); CC (entry->components, 4, val, maxlen); if (t >= 4) return NULL; vs = exif_get_short (entry->data + t * 2, entry->order); Kind regards, Jan Patera > Marcus Meissner wrote: >> On Wed, Sep 06, 2006 at 03:39:30PM +0200, Jef Driesen wrote: >>> Jan Patera wrote: >>>>> case MNOTE_CANON_TAG_FOCAL_LENGTH: >>>>> CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); >>>>> n = exif_get_short (data, entry->order) / 2; >>>>> if (t >= n) return NULL; >>>>> CC (entry->components, n, val, maxlen); >>>>> vs = exif_get_short (entry->data + 2 + t * 2, entry->order); >>>>> snprintf (buf, sizeof (buf), "0x%04x", vs); >>>>> strncpy (val, buf, maxlen - strlen (val)); >>>>> break; >>>>> >>>>> But when I run the exif commandline utility, an error is reported >>>>> for the new tag: >>>>> >>>>> Focal type |Invalid number of components (4, expected 1). >>>>> >>>>> What am I doing wrong here? >>>> >>>> this message is printed by the CC macro. It checks whether >>>> 1st & 2nd arguments are equal. apparently entry->components is 4, >>>> but n is only 1. >>> I knew it was reported by the CC macro, but I don't understand why it >>> is happening. It is exactly the same code as is used for >>> MNOTE_CANON_TAG_SETTINGS_1 (which also has multiple components), but >>> no error there! Probably I forgot to add some code somewhere else, >>> but I don't see it. >> >> Just a wild guess: >> Did you adjust mnote_canon_entry_count_values() too? > > I added an extra 'case MNOTE_CANON_TAG_FOCAL_LENGTH:' between the > others. |
From: Jef D. <jef...@ho...> - 2006-09-06 18:33:58
|
Jan Patera wrote: >> Marcus Meissner wrote: >>> On Wed, Sep 06, 2006 at 03:39:30PM +0200, Jef Driesen wrote: >>>> Jan Patera wrote: >>>>>> case MNOTE_CANON_TAG_FOCAL_LENGTH: >>>>>> CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); >>>>>> n = exif_get_short (data, entry->order) / 2; >>>>>> if (t >= n) return NULL; >>>>>> CC (entry->components, n, val, maxlen); >>>>>> vs = exif_get_short (entry->data + 2 + t * 2, entry->order); >>>>>> snprintf (buf, sizeof (buf), "0x%04x", vs); >>>>>> strncpy (val, buf, maxlen - strlen (val)); >>>>>> break; >>>>>> >>>>>> But when I run the exif commandline utility, an error is reported >>>>>> for the new tag: >>>>>> >>>>>> Focal type |Invalid number of components (4, expected 1). >>>>>> >>>>>> What am I doing wrong here? >>>>> this message is printed by the CC macro. It checks whether >>>>> 1st & 2nd arguments are equal. apparently entry->components is 4, >>>>> but n is only 1. >>>> I knew it was reported by the CC macro, but I don't understand why it >>>> is happening. It is exactly the same code as is used for >>>> MNOTE_CANON_TAG_SETTINGS_1 (which also has multiple components), but >>>> no error there! Probably I forgot to add some code somewhere else, >>>> but I don't see it. >>> Just a wild guess: >>> Did you adjust mnote_canon_entry_count_values() too? >> I added an extra 'case MNOTE_CANON_TAG_FOCAL_LENGTH:' between the >> others. > > I inspected > http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Canon.html#FocalLength > and here is what I have found out: > 1) MNOTE_CANON_TAG_FOCAL_LENGTH data is expected to be of the > EXIF_FORMAT_SHORT format and to have 4 items > 2) the 1st value is FocalType, and not size of any kind. > > I inspected > http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Canon.html#FocalLength > and here is what I have found out: > 1) MNOTE_CANON_TAG_FOCAL_LENGTH data is expected to be of the > EXIF_FORMAT_SHORT format and to have 4 items > 2) the 1st value is FocalType, and not size of any kind. > > Thus the correct sanity checks & code are: > CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); > CC (entry->components, 4, val, maxlen); > if (t >= 4) return NULL; > vs = exif_get_short (entry->data + t * 2, entry->order); I assumed that tags always have a variable size and therefore always have a length field. Because entry->components has the correct information (without specifying this value myself), I assumed that it came from this first value. In the exiftool documentation, all the offsets start at one (with the exception of this FocalLength tag), while in libexif numbering starts at zero. I assumed this FocalLength offset was a mistake in the documentation. I'll need to investigate this further. |
From: Jan P. <pa...@pi...> - 2006-09-06 14:26:01
|
Apparently the data associated to tag MNOTE_CANON_TAG_FOCAL_LENGTH have four short int values (because entry->components is 4). The first value is 2 (you get 1 after dividing by 2). Is this what you expect? Are you familiar with the format of the data of this tag (I am not)? -- Jan Apparent > Jan Patera wrote: >>> case MNOTE_CANON_TAG_FOCAL_LENGTH: >>> CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); >>> n = exif_get_short (data, entry->order) / 2; >>> if (t >= n) return NULL; >>> CC (entry->components, n, val, maxlen); >>> vs = exif_get_short (entry->data + 2 + t * 2, entry->order); >>> snprintf (buf, sizeof (buf), "0x%04x", vs); >>> strncpy (val, buf, maxlen - strlen (val)); >>> break; >>> >>> But when I run the exif commandline utility, an error is reported for >>> the new tag: >>> >>> Focal type |Invalid number of components (4, expected 1). >>> >>> What am I doing wrong here? >> >> >> this message is printed by the CC macro. It checks whether >> 1st & 2nd arguments are equal. apparently entry->components is 4, but >> n is only 1. > > I knew it was reported by the CC macro, but I don't understand why it is > happening. It is exactly the same code as is used for > MNOTE_CANON_TAG_SETTINGS_1 (which also has multiple components), but no > error there! Probably I forgot to add some code somewhere else, but I > don't see it. |
From: Jef D. <jef...@ho...> - 2006-09-06 14:30:54
|
Marcus Meissner wrote: > On Wed, Sep 06, 2006 at 03:39:30PM +0200, Jef Driesen wrote: >> Jan Patera wrote: >>>> case MNOTE_CANON_TAG_FOCAL_LENGTH: >>>> CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); >>>> n = exif_get_short (data, entry->order) / 2; >>>> if (t >= n) return NULL; >>>> CC (entry->components, n, val, maxlen); >>>> vs = exif_get_short (entry->data + 2 + t * 2, entry->order); >>>> snprintf (buf, sizeof (buf), "0x%04x", vs); >>>> strncpy (val, buf, maxlen - strlen (val)); >>>> break; >>>> >>>> But when I run the exif commandline utility, an error is reported for >>>> the new tag: >>>> >>>> Focal type |Invalid number of components (4, expected 1). >>>> >>>> What am I doing wrong here? >>> >>> this message is printed by the CC macro. It checks whether >>> 1st & 2nd arguments are equal. apparently entry->components is 4, >>> but n is only 1. >> I knew it was reported by the CC macro, but I don't understand why it is >> happening. It is exactly the same code as is used for >> MNOTE_CANON_TAG_SETTINGS_1 (which also has multiple components), but no >> error there! Probably I forgot to add some code somewhere else, but I >> don't see it. > > Just a wild guess: > Did you adjust mnote_canon_entry_count_values() too? I added an extra 'case MNOTE_CANON_TAG_FOCAL_LENGTH:' between the others. |
From: Jef D. <jef...@ho...> - 2006-09-12 13:34:44
|
Jef Driesen wrote: > Many makernote tags are already documented by the 'exiftool' project > [1], but are not in the libexif library. I'm working on adding those > canon makernotes to the libexif library. > > [1] http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Canon.html I finished updating the libexif library with canon makernotes. I have created three patches (mnote-canon-tag.h, mnote-canon-tag.c and mnote-canon-entry.c) against the cvs version. How do I contribute this work? An overview of the changes: * Some tags were updated from exiftool: - MNOTE_CANON_TAG_SETTINGS_1 - MNOTE_CANON_TAG_SETTINGS_2 I also intended to change there names to some more meaningful values, like used in exiftool (respectively CAMERA_SETTINGS and SHOT_INFO), but I'm not sure if that will break existing applications. The only tag I did not update is the lenstype. * Some new tags were added from exiftool: - MNOTE_CANON_TAG_FOCAL_LENGTH - MNOTE_CANON_TAG_PANORAMA * All other tags (documented or not by exiftool) do not contain very useful information (for the only camera I own), and were not added. Maybe later, who knows... * Added some internal functions to convert apex values to aperture/shutterspeed/iso values. Also moved the code for the table lookups to separate functions. * Added a "Manual flash output" tag (actually there are two), obtained by reverse engineering. It works for my camera, but I don't know for others! For some tags, exiftool lists exceptions for specific type of camera's. I did not incorporate that information, because I don't have those camera's to test. I checked everything very carefully, but there could still be some mistakes... |
From: Hubert F. <hu...@fi...> - 2006-09-12 16:13:09
|
On Tuesday 12 September 2006 09:35, Jef Driesen wrote: > I finished updating the libexif library with canon makernotes. I have > created three patches (mnote-canon-tag.h, mnote-canon-tag.c and > mnote-canon-entry.c) against the cvs version. How do I contribute this > work? cvd diff -u to the mailing list, as "attachment" Hub |
From: Jef D. <jef...@ho...> - 2006-09-12 18:46:41
Attachments:
patch.diff
|
Hubert Figuiere wrote: > On Tuesday 12 September 2006 09:35, Jef Driesen wrote: >> I finished updating the libexif library with canon makernotes. I have >> created three patches (mnote-canon-tag.h, mnote-canon-tag.c and >> mnote-canon-entry.c) against the cvs version. How do I contribute this >> work? > > cvd diff -u to the mailing list, as "attachment" See attachment for the patch! |
From: Lutz <lu...@to...> - 2006-09-17 10:19:52
|
On Tue, 2006-09-12 at 20:45 +0200, Jef Driesen wrote: > See attachment for the patch! Applied. Thank you for your work! --=20 Lutz M=FCller <lu...@to...> |