tag: exif: wrong parsing of ISO_SPEED and PHOTOGRAPHIC_SENSITIVITY tags
Submitted by Paulo Neves
Link to original bug (#764093)
Description
Created attachment 324607
A proposed patch.
The comments below take into account the standard description summary found in
http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html
According to the site above:
0x8827 is ISO or PhotographicSensitivity in EXIF2.3
0x8833 is ISOSpeed (dependent of SensitivityType in ExifISOTag)
According to gstexif.c:
0x8827 is EXIF_TAG_PHOTOGRAPHIC_SENSITIVITY
0x8833 is EXIF_TAG_ISO_SPEED
Then we have following in gstexif.c@373
/* don't need the serializer as we always write the iso speed alone */
{GST_TAG_CAPTURING_ISO_SPEED, EXIF_TAG_PHOTOGRAPHIC_SENSITIVITY,
EXIF_TYPE_SHORT, 0, NULL,
deserialize_add_to_pending_tags},
{GST_TAG_CAPTURING_ISO_SPEED, EXIF_TAG_SENSITIVITY_TYPE, EXIF_TYPE_SHORT, 0,
serialize_sensitivity_type, deserialize_sensitivity_type},
{GST_TAG_CAPTURING_ISO_SPEED, EXIF_TAG_ISO_SPEED, EXIF_TYPE_LONG, 0, NULL,
NULL},
Which means that EXIF_TAG_PHOTOGRAPHIC_SENSITIVITY will have deferred parsing depending on the EXIF_TAG_SENSITIVITY_TYPE which is wrong as seen from the relation established before in the site.
Instead, the Tag dependent on EXIF_TAG_SENSITIVITY_TYPE should be EXIF_TAG_ISO_SPEED which is not happening.
This creates a bug that results in the ISO parameter never being parsed. A scenario where this happens is if Sensitivity Type is different than 3 (ISO Speed) and instead is 2 (Recommended Exposure Index). What will happen is that no EXIF_TAG_ISO_SPEED (0X8833) will exist because the type is 2 and the deferred EXIF_TAG_PHOTOGRAPHIC_SENSITIVITY (0x8827) was discarded in the SensitivityType parsing because type is different than 3. No more ISO information can be retrieved from the file.
So assuming we now correctly make the EXIF_TAG_ISO_SPEED dependent on the EXIF_TAG_SENSITIVITY_TYPE and leave the EXIF_TAG_PHOTOGRAPHIC_SENSITIVITY correctly represent the GST_TAG_CAPTURING_ISO_SPEED the problem outlined before does not happen because a standard compliant exif field will not even have EXIF_TAG_ISO_SPEED if the EXIF_TAG_SENSITIVITY_TYPE is different than 3. For the example above where the EXIF_TAG_SENSITIVITY_TYPE is 2, the exif will have a RecommendedExposureIndex (0x8832) tag which is currently not handled. The EXIF_TAG_PHOTOGRAPHIC_SENSITIVITY would then be parseable and not dependent on anything.
The problem is that EXIF_TAG_PHOTOGRAPHIC_SENSITIVITY is of size type EXIF_TYPE_SHORT which for a reason I do not understand does not have a function that parses shorts like parse_exif_<type>
_tag. This happens with other types. I propose thus the following:
static void parse_exif_short_tag(GstExifReader * reader, const GstExifTagMatch tag, guint32 count, guint32 offset, const guint8 * offset_as_data)
This way in gstexif.c@parse_exif_long_tag we can parse EXIF_TYPE_SHORTs.
With everything together the problem is solved on my side.
I attach a proposed patch.
Hoping I was clear and thankful for Gstreamer
Paulo Neves
Patch 324607, "A proposed patch.":
ISO_tag.patch