From patchwork Mon May 4 07:04:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3681 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2C1E7603F2 for ; Mon, 4 May 2020 09:04:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="dsVUEyr8"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9DD39304 for ; Mon, 4 May 2020 09:04:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1588575877; bh=cieFPV82b2T09IQCGVwp6Ec14rDwu5MXed6n7pm3SYE=; h=From:To:Subject:Date:From; b=dsVUEyr88/EkDA6q587zUuXPg0tFB+VinQePqvfiTl0uC92agvsnF+Xg8ojg1Ybx2 DvcxPUoBLg1Cd2ZrAyQYrZWl2+vzJmusVQ7BuGPHcPzqi6BBttSOLo6b7ylGVv9lQs HEJxjH+QXa2PjeSlB73FOIN08RJQDUIosoxaHpPs= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 4 May 2020 10:04:25 +0300 Message-Id: <20200504070425.5972-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] qcam: dng_writer: Write EXIF IFD as custom directory X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2020 07:04:38 -0000 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 Reviewed-by: Niklas Söderlund Reviewed-by: Kieran Bingham --- src/qcam/dng_writer.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/qcam/dng_writer.cpp b/src/qcam/dng_writer.cpp index ea4616f63d8e..cbd8bed3e6d0 100644 --- a/src/qcam/dng_writer.cpp +++ b/src/qcam/dng_writer.cpp @@ -316,9 +316,7 @@ int DNGWriter::write(const char *filename, const Camera *camera, TIFFSetField(tif, EXIFTAG_EXPOSURETIME, exposureTime); } - TIFFCheckpointDirectory(tif); - exifIFDOffset = TIFFCurrentDirOffset(tif); - TIFFWriteDirectory(tif); + TIFFWriteCustomDirectory(tif, &exifIFDOffset); /* Update the IFD offsets and close the file. */ TIFFSetDirectory(tif, 0);