qcam: dng_writer: Write EXIF IFD as custom directory

The EXIF IFD is incorrectly chained to IFD 0 in addition to being a
referenced as a sub IFD through the EXIFIFD tag. While the libtiff API
doesn't clearly document why this happens, inspection of the
TIFFWriteDirectory() source code show that the function treats the IFD
being written as containing an image, which isn't correct for the EXIF
IFD. Use TIFFWriteCustomDirectory() instead, which fixes the problem.
The resulting DNG file can now be opened with darktable in addition to
rawtherapee.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Laurent Pinchart 2020-05-04 06:29:46 +03:00
parent b3987620aa
commit 3ed0fced1f

View file

@ -316,9 +316,7 @@ int DNGWriter::write(const char *filename, const Camera *camera,
TIFFSetField(tif, EXIFTAG_EXPOSURETIME, exposureTime); TIFFSetField(tif, EXIFTAG_EXPOSURETIME, exposureTime);
} }
TIFFCheckpointDirectory(tif); TIFFWriteCustomDirectory(tif, &exifIFDOffset);
exifIFDOffset = TIFFCurrentDirOffset(tif);
TIFFWriteDirectory(tif);
/* Update the IFD offsets and close the file. */ /* Update the IFD offsets and close the file. */
TIFFSetDirectory(tif, 0); TIFFSetDirectory(tif, 0);