Project

General

Profile

SByte: shows as Byte

Added by Norbert Wagner almost 9 years ago

The tag Exif.NikonAFT.AFFineTuneAdj is according documentation of type "SByte" and in the source code I also see that it is configured as "signedByte". But when I access to this tag using the API it shows up as "Byte. Also when run the command line tool it shows as Byte. Any idea how to recognize the correct type?


Replies (7)

RE: SByte: shows as Byte - Added by Robin Mills almost 9 years ago

Norbet

I don't know anything about this, however I'm going to suggest how to solve this. This sounds like a bug. I don't have an image with either an SByte or a Byte tag, however if I did, I would walk the code in the debugger for each. There must be a significant difference. When you know what that is, you'll have your solution. If it's a bug, I'll be happy to submit your patch. If you give me suitable images, I'll debug it.

Robin

RE: SByte: shows as Byte - Added by Norbert Wagner almost 9 years ago

Hello Robin,

thanks a lot for the fast response. Here an example picture. It contains among others the group "Nikon AF Fine Tune Tags" with two tags of type Byte (keys Exif.NikonAFT.AFFineTune and Exif.NikonAFT.AFFineTuneIndex, tags 0x0000 and 0x0001) and one SByte with key Exif.NikonAFT.AFFineTuneAdj, tag 0x0002.

Kind regards - and the best wishes for 2013

Norbert

RE: SByte: shows as Byte - Added by Robin Mills almost 9 years ago

Norbert

Thanks for posting the file. I'm on vacation at the moment. I'll have a look at this when I get home to Silicon Valley on New Year's Day.

Best Wishes to you for 2013.

RE: SByte: shows as Byte - Added by Robin Mills almost 9 years ago

Norbert

I've reproduced your finding. I haven't solved this yet, however I'm making progress. I didn't write the code, so its the usual mystery of discovery. However my suspicion is that the function:

TiffReader::visitBinaryElement(TiffBinaryElement* object) in tiffvisitor.cpp lost the type information.

The tag AFFineTuneAdj is the only tag in exiv2 of type signedByte, so the ugly fix is in toTypeId(type,tag,group), in tiffcomposite.cpp

// *************************************************************************
// free functions
TypeId toTypeId(TiffType tiffType, uint16_t tag, IfdId group)
{
    TypeId ti = TypeId(tiffType);
    // On the fly type conversion for Exif.Photo.UserComment
    if (tag == 0x9286 && group == exifId && ti == undefined) {
        ti = comment;
    }

    // http://dev.exiv2.org/boards/3/topics/1337
    // Exif.NikonAFT.AFFineTuneAdj should be signedByte
    if ( tag == 0x0002 && group == nikonAFTId && ti == unsignedByte ) {
        ti = signedByte;
    }

    return ti;
}

This is an ugly fix because it doesn't scale. Every signedByte tag would require special code. I have not submitted this to the trunk. I will walk the code again at the weekend and find a better solution - however this is OK for now. I notice that you also have a 0x0003 tag in your image. Do you know what that is?

Robin

RE: SByte: shows as Byte - Added by Robin Mills almost 9 years ago

I've spent more time on this matter and decided that the fix above is "for the best". Fix submitted SVN: 2960

There are several reasons:

1) This fix involves no risk to any other tag.
2) The fix doesn't scale, however there only one signedByte tag at present.
3) I have been unable to find Nikon Documentation to confirm the definition of Exif.NikonAFT.AFFineTuneAdj as signedByte.
I've discussed my search here: http://dev.exiv2.org/boards/3/topics/1353

I discovered a couple of interesting things.

You can look up the typeId in the registry with the code:

    ti = Exiv2::Internal::tagInfo(tag,group)->typeId_;

When I tested this in toTypeId, I received a warning from exifprint. I suspect the registry can define a typeId, and the file may contain a different definition.

I also tested modifying the TiffBinaryElement constructor as follows:

    TiffBinaryElement::TiffBinaryElement(uint16_t tag, IfdId group)
        : TiffEntryBase(tag, group,Exiv2::Internal::tagInfo(tag,group)->typeId_)
    {
    }

This was ineffective. The default type for TiffEntryBase(tag,group) is undefined. Therefore there is something in the file which caused TiffReader to set the tag's typeId as unsignedByte. This is my most compelling reason to limit the fix to only this tag.

Robin

RE: SByte: shows as Byte - Added by Norbert Wagner almost 9 years ago

Hello Robin,

thanks for the investigation. Some more information from my side:

According to documentation of exiv2 there is one other SByte: Exif.Pentax.Temperature (Tag 0x0047), so I suggest to add this to Your fix. Well, it is an ugly fix but in many years of programming I have learnt that avoiding ugly fixes is sometimes just to time consuming.
The Exif.NikonAFT.AFFineTuneAdj can be set via menu and in my camery (D7000) it can have a value from -20 to +20. So it is really a signed number.
I tried to find out what tag 0x0003 means, but whatever I adjust related to AF-Fine-Tune (I assume that is the meaning of AFT) my pictures have the value 0.

Norbert

RE: SByte: shows as Byte - Added by Robin Mills almost 9 years ago

Thanks, Norbert.

I missed Exif.Pentax.Temperature. DevStudio found that instance of unsignedByte in the code. My old eyes failed to however notice that earlier this week.

I've updated my fix and submitted SVN:2962

Robin

    (1-7/7)