From patchwork Tue Jun 25 08:01:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20384 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 40633BDB1D for ; Tue, 25 Jun 2024 08:01:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 77DD8654A9; Tue, 25 Jun 2024 10:01:27 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="tHs9aA2n"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 417F1619E8 for ; Tue, 25 Jun 2024 10:01:25 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:ac8e:9f5c:939f:7f08]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8A82DFF1; Tue, 25 Jun 2024 10:01:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1719302462; bh=HVkwOYfmGFjLQYlQrCN533VQw654U3SKYuz44G+1fok=; h=From:To:Cc:Subject:Date:From; b=tHs9aA2n2wVSoAZSUVPYjyf0u+vN/sXATtd8hU+0THe5vtMxCfffl5ZKBuOL7Hw3u 5awn4ZwiMX62unryaRaL/hSTY7ldnk0Psg3OcEsKdcdhQfzFgspjNLjEHi3OdRpKFf tit478JCibiGta/omz31jp4TPvOpY8Kx03Y6bWyU= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH] apps: common: dng_writer: Workaround for "Unknown tag 33421" error Date: Tue, 25 Jun 2024 10:01:11 +0200 Message-ID: <20240625080119.1905870-1-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" In libtiff version 4.5.1 and later the CFA* tags were missing. This got fixed in https://gitlab.com/libtiff/libtiff/-/commit/49856998c3d82e65444b47bb4fb11b7830a0c2be Unfortunately the fix is not released yet, but the faulty libtiff is contained in current buildroot. As a local fix is pretty easy and without side effects, let's workaround that. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/apps/common/dng_writer.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/apps/common/dng_writer.cpp b/src/apps/common/dng_writer.cpp index 103e5c828c4d..7375577e920f 100644 --- a/src/apps/common/dng_writer.cpp +++ b/src/apps/common/dng_writer.cpp @@ -541,6 +541,23 @@ int DNGWriter::write(const char *filename, const Camera *camera, TIFFWriteDirectory(tif); + /* + * Workaround for a bug introduced in libtiff version 4.5.1 and no fix + * released. In these versions the CFA* tags were missing in the field + * info. + * Introduced by: https://gitlab.com/libtiff/libtiff/-/commit/738e04099b13192bb1f654e74e9b5829313f3161 + * Fixed by: https://gitlab.com/libtiff/libtiff/-/commit/49856998c3d82e65444b47bb4fb11b7830a0c2be + */ + if (!TIFFFindField(tif, TIFFTAG_CFAREPEATPATTERNDIM, TIFF_ANY)) { + static const TIFFFieldInfo infos[] = { + { TIFFTAG_EP_CFAREPEATPATTERNDIM, 2, 2, TIFF_SHORT, FIELD_CUSTOM, + 1, 0, const_cast("EP CFARepeatPatternDim") }, + { TIFFTAG_EP_CFAPATTERN, -1, -1, TIFF_BYTE, FIELD_CUSTOM, + 1, 1, const_cast("EP CFAPattern") }, + }; + TIFFMergeFieldInfo(tif, infos, 2); + } + /* Create a new IFD for the RAW image. */ const uint16_t cfaRepeatPatternDim[] = { 2, 2 }; const uint8_t cfaPlaneColor[] = {