[{"id":30070,"web_url":"https://patchwork.libcamera.org/comment/30070/","msgid":"<171930419943.403337.17002733473626307325@ping.linuxembedded.co.uk>","date":"2024-06-25T08:29:59","subject":"Re: [PATCH] apps: common: dng_writer: Workaround for \"Unknown tag\n\t33421\" error","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2024-06-25 09:01:11)\n> In libtiff version 4.5.1 and later the CFA* tags were missing. This got\n> fixed in https://gitlab.com/libtiff/libtiff/-/commit/49856998c3d82e65444b47bb4fb11b7830a0c2be\n> Unfortunately the fix is not released yet, but the faulty libtiff is\n> contained in current buildroot. As a local fix is pretty easy and\n> without side effects, let's workaround that.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  src/apps/common/dng_writer.cpp | 17 +++++++++++++++++\n>  1 file changed, 17 insertions(+)\n> \n> diff --git a/src/apps/common/dng_writer.cpp b/src/apps/common/dng_writer.cpp\n> index 103e5c828c4d..7375577e920f 100644\n> --- a/src/apps/common/dng_writer.cpp\n> +++ b/src/apps/common/dng_writer.cpp\n> @@ -541,6 +541,23 @@ int DNGWriter::write(const char *filename, const Camera *camera,\n>  \n>         TIFFWriteDirectory(tif);\n>  \n> +       /*\n> +        * Workaround for a bug introduced in libtiff version 4.5.1 and no fix\n> +        * released. In these versions the CFA* tags were missing in the field\n> +        * info.\n> +        * Introduced by: https://gitlab.com/libtiff/libtiff/-/commit/738e04099b13192bb1f654e74e9b5829313f3161\n> +        * Fixed by: https://gitlab.com/libtiff/libtiff/-/commit/49856998c3d82e65444b47bb4fb11b7830a0c2be\n> +        */\n> +       if (!TIFFFindField(tif, TIFFTAG_CFAREPEATPATTERNDIM, TIFF_ANY)) {\n> +               static const TIFFFieldInfo infos[] = {\n> +                       { TIFFTAG_EP_CFAREPEATPATTERNDIM, 2, 2, TIFF_SHORT, FIELD_CUSTOM,\n> +                         1, 0, const_cast<char *>(\"EP CFARepeatPatternDim\") },\n> +                       { TIFFTAG_EP_CFAPATTERN, -1, -1, TIFF_BYTE, FIELD_CUSTOM,\n> +                         1, 1, const_cast<char *>(\"EP CFAPattern\") },\n> +               };\n\nAs a workaround it sounds fine, but shouldn't there be something here\nwhich writes out the pattern based on the metadata/properties of the\ncamera/raw stream? Or are these always fixed data entries?\n\nAha, actually I think I see this is preparing the fields so that it can\nbe set below!\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> +               TIFFMergeFieldInfo(tif, infos, 2);\n> +       }\n> +\n>         /* Create a new IFD for the RAW image. */\n>         const uint16_t cfaRepeatPatternDim[] = { 2, 2 };\n>         const uint8_t cfaPlaneColor[] = {\n> -- \n> 2.43.0\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 2E649BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Jun 2024 08:30:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E4747654A9;\n\tTue, 25 Jun 2024 10:30:03 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 287CD619E8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Jun 2024 10:30:02 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9E6FEBEB;\n\tTue, 25 Jun 2024 10:29:39 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"MwgONVFp\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1719304179;\n\tbh=lxkqqir9vMlM4TBkjYrztZrC4kxb1EKR6aKEP7/82c8=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=MwgONVFp2N3tbn8Fj9y+xsISuQjG7QGo0QtDUUeRDHPwBvJJ93RJqzhD00RKNZL6k\n\tFvEbykBNx0SAvrNO7P1s1gULvuJAnKJGj7aCrJa5QvIsgjUjrVRya+4KNRoRY9iiIn\n\tLmYWcU2txuhRuNTdmLDMcbh1wd/z31YqgeW8PH8g=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240625080119.1905870-1-stefan.klug@ideasonboard.com>","References":"<20240625080119.1905870-1-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH] apps: common: dng_writer: Workaround for \"Unknown tag\n\t33421\" error","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Tue, 25 Jun 2024 09:29:59 +0100","Message-ID":"<171930419943.403337.17002733473626307325@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":30072,"web_url":"https://patchwork.libcamera.org/comment/30072/","msgid":"<20240625084348.GA30459@pendragon.ideasonboard.com>","date":"2024-06-25T08:43:48","subject":"Re: [PATCH] apps: common: dng_writer: Workaround for \"Unknown tag\n\t33421\" error","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Stefan,\n\nThank you for the patch.\n\nOn Tue, Jun 25, 2024 at 10:01:11AM +0200, Stefan Klug wrote:\n> In libtiff version 4.5.1 and later the CFA* tags were missing. This got\n> fixed in https://gitlab.com/libtiff/libtiff/-/commit/49856998c3d82e65444b47bb4fb11b7830a0c2be\n> Unfortunately the fix is not released yet, but the faulty libtiff is\n> contained in current buildroot. As a local fix is pretty easy and\n> without side effects, let's workaround that.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  src/apps/common/dng_writer.cpp | 17 +++++++++++++++++\n>  1 file changed, 17 insertions(+)\n> \n> diff --git a/src/apps/common/dng_writer.cpp b/src/apps/common/dng_writer.cpp\n> index 103e5c828c4d..7375577e920f 100644\n> --- a/src/apps/common/dng_writer.cpp\n> +++ b/src/apps/common/dng_writer.cpp\n> @@ -541,6 +541,23 @@ int DNGWriter::write(const char *filename, const Camera *camera,\n>  \n>  \tTIFFWriteDirectory(tif);\n>  \n> +\t/*\n> +\t * Workaround for a bug introduced in libtiff version 4.5.1 and no fix\n> +\t * released. In these versions the CFA* tags were missing in the field\n> +\t * info.\n> +\t * Introduced by: https://gitlab.com/libtiff/libtiff/-/commit/738e04099b13192bb1f654e74e9b5829313f3161\n> +\t * Fixed by: https://gitlab.com/libtiff/libtiff/-/commit/49856998c3d82e65444b47bb4fb11b7830a0c2be\n> +\t */\n> +\tif (!TIFFFindField(tif, TIFFTAG_CFAREPEATPATTERNDIM, TIFF_ANY)) {\n> +\t\tstatic const TIFFFieldInfo infos[] = {\n> +\t\t\t{ TIFFTAG_EP_CFAREPEATPATTERNDIM, 2, 2, TIFF_SHORT, FIELD_CUSTOM,\n> +\t\t\t  1, 0, const_cast<char *>(\"EP CFARepeatPatternDim\") },\n> +\t\t\t{ TIFFTAG_EP_CFAPATTERN, -1, -1, TIFF_BYTE, FIELD_CUSTOM,\n> +\t\t\t  1, 1, const_cast<char *>(\"EP CFAPattern\") },\n\nThis will fail to compile with libtiff versions older than v4.5.1, where\nthe bug was introduced. TIFFTAG_CFAREPEATPATTERNDIM and\nTIFFTAG_CFAPATTERN became aliases for TIFFTAG_EP_CFAREPEATPATTERNDIM and\nTIFFTAG_EP_CFAPATTERN in that version, so I think you can switch to\nTIFFTAG_CFAREPEATPATTERNDIM and TIFFTAG_CFAPATTERN here. I would also\nchange the description string to drop the \"EP \" prefix.\n\nWith that,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t\t};\n> +\t\tTIFFMergeFieldInfo(tif, infos, 2);\n> +\t}\n> +\n>  \t/* Create a new IFD for the RAW image. */\n>  \tconst uint16_t cfaRepeatPatternDim[] = { 2, 2 };\n>  \tconst uint8_t cfaPlaneColor[] = {","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 1AB06BDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Jun 2024 08:44:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3E6D5654A4;\n\tTue, 25 Jun 2024 10:44:11 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7E45A654A1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Jun 2024 10:44:09 +0200 (CEST)","from pendragon.ideasonboard.com (unknown [193.209.96.36])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CA292BEB;\n\tTue, 25 Jun 2024 10:43:46 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"phslejyz\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1719305027;\n\tbh=EyunNBYVy8dB0jBVRe0CcFPOcmtSnCcvozJ7a+pwGTI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=phslejyz/cBOoFGEWdibx5jit940EGIPPFyVRVESYma7k2jP7EKLPNPD1F34ZSTE6\n\thV3GG0LK4648n0brf4TMasd2TneTRgIBPPqtXl+N+PlsGpmU8FAT4/DTHYiLJZBsoi\n\tYoDrQmqeFNAjcesrkrwr70c62nSkzAF0/r0xuDsU=","Date":"Tue, 25 Jun 2024 11:43:48 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH] apps: common: dng_writer: Workaround for \"Unknown tag\n\t33421\" error","Message-ID":"<20240625084348.GA30459@pendragon.ideasonboard.com>","References":"<20240625080119.1905870-1-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240625080119.1905870-1-stefan.klug@ideasonboard.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":30073,"web_url":"https://patchwork.libcamera.org/comment/30073/","msgid":"<171930519989.403337.1636836981216593847@ping.linuxembedded.co.uk>","date":"2024-06-25T08:46:39","subject":"Re: [PATCH] apps: common: dng_writer: Workaround for \"Unknown tag\n\t33421\" error","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2024-06-25 09:43:48)\n> Hi Stefan,\n> \n> Thank you for the patch.\n> \n> On Tue, Jun 25, 2024 at 10:01:11AM +0200, Stefan Klug wrote:\n> > In libtiff version 4.5.1 and later the CFA* tags were missing. This got\n> > fixed in https://gitlab.com/libtiff/libtiff/-/commit/49856998c3d82e65444b47bb4fb11b7830a0c2be\n> > Unfortunately the fix is not released yet, but the faulty libtiff is\n> > contained in current buildroot. As a local fix is pretty easy and\n> > without side effects, let's workaround that.\n> > \n> > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > ---\n> >  src/apps/common/dng_writer.cpp | 17 +++++++++++++++++\n> >  1 file changed, 17 insertions(+)\n> > \n> > diff --git a/src/apps/common/dng_writer.cpp b/src/apps/common/dng_writer.cpp\n> > index 103e5c828c4d..7375577e920f 100644\n> > --- a/src/apps/common/dng_writer.cpp\n> > +++ b/src/apps/common/dng_writer.cpp\n> > @@ -541,6 +541,23 @@ int DNGWriter::write(const char *filename, const Camera *camera,\n> >  \n> >       TIFFWriteDirectory(tif);\n> >  \n> > +     /*\n> > +      * Workaround for a bug introduced in libtiff version 4.5.1 and no fix\n> > +      * released. In these versions the CFA* tags were missing in the field\n> > +      * info.\n> > +      * Introduced by: https://gitlab.com/libtiff/libtiff/-/commit/738e04099b13192bb1f654e74e9b5829313f3161\n> > +      * Fixed by: https://gitlab.com/libtiff/libtiff/-/commit/49856998c3d82e65444b47bb4fb11b7830a0c2be\n> > +      */\n> > +     if (!TIFFFindField(tif, TIFFTAG_CFAREPEATPATTERNDIM, TIFF_ANY)) {\n> > +             static const TIFFFieldInfo infos[] = {\n> > +                     { TIFFTAG_EP_CFAREPEATPATTERNDIM, 2, 2, TIFF_SHORT, FIELD_CUSTOM,\n> > +                       1, 0, const_cast<char *>(\"EP CFARepeatPatternDim\") },\n> > +                     { TIFFTAG_EP_CFAPATTERN, -1, -1, TIFF_BYTE, FIELD_CUSTOM,\n> > +                       1, 1, const_cast<char *>(\"EP CFAPattern\") },\n> \n> This will fail to compile with libtiff versions older than v4.5.1, where\n> the bug was introduced. TIFFTAG_CFAREPEATPATTERNDIM and\n> TIFFTAG_CFAPATTERN became aliases for TIFFTAG_EP_CFAREPEATPATTERNDIM and\n> TIFFTAG_EP_CFAPATTERN in that version, so I think you can switch to\n> TIFFTAG_CFAREPEATPATTERNDIM and TIFFTAG_CFAPATTERN here. I would also\n> change the description string to drop the \"EP \" prefix.\n\nhttps://gitlab.freedesktop.org/camera/libcamera/-/pipelines/1209546\nshows failures. It could be the above - or something else, either way\nneeds to be checked.\n\n--\nKieran\n\n\n> \n> With that,\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> > +             };\n> > +             TIFFMergeFieldInfo(tif, infos, 2);\n> > +     }\n> > +\n> >       /* Create a new IFD for the RAW image. */\n> >       const uint16_t cfaRepeatPatternDim[] = { 2, 2 };\n> >       const uint8_t cfaPlaneColor[] = {\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id DAB12BDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Jun 2024 08:46:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 12A40654A9;\n\tTue, 25 Jun 2024 10:46:44 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C5D1A619E8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Jun 2024 10:46:42 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5FF60BEB;\n\tTue, 25 Jun 2024 10:46:20 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"dBxYGQEF\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1719305180;\n\tbh=ZMgNSQpjP10YtmT55JEy6WUyvs4J/mW4OGyUgw6P4HE=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=dBxYGQEFLSmjBjUMWHoyeOui0my8PSKtcYD30hhUiDeS1K/flDjGaEMcVPMYkyHcF\n\tn7xnMUKc9lUvy/Jfe8D6vFReATkOzJTVP0eMJuS0SQ8P58wrdt5bQHEW6iPB94rys3\n\tWUKAIyKrbq9AqU9DcxIZZKateDQHdhE7gxTuH6po=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240625084348.GA30459@pendragon.ideasonboard.com>","References":"<20240625080119.1905870-1-stefan.klug@ideasonboard.com>\n\t<20240625084348.GA30459@pendragon.ideasonboard.com>","Subject":"Re: [PATCH] apps: common: dng_writer: Workaround for \"Unknown tag\n\t33421\" error","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tStefan Klug <stefan.klug@ideasonboard.com>","Date":"Tue, 25 Jun 2024 09:46:39 +0100","Message-ID":"<171930519989.403337.1636836981216593847@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":30074,"web_url":"https://patchwork.libcamera.org/comment/30074/","msgid":"<ysbzjtoy2eihl7utnsoedamckywkbkfazztybwkf62dheil57j@mdopy3l32yft>","date":"2024-06-25T08:50:08","subject":"Re: [PATCH] apps: common: dng_writer: Workaround for \"Unknown tag\n\t33421\" error","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"content":"Hi Laurent,\n\n\nOn Tue, Jun 25, 2024 at 11:43:48AM +0300, Laurent Pinchart wrote:\n> Hi Stefan,\n> \n> Thank you for the patch.\n> \n> On Tue, Jun 25, 2024 at 10:01:11AM +0200, Stefan Klug wrote:\n> > In libtiff version 4.5.1 and later the CFA* tags were missing. This got\n> > fixed in https://gitlab.com/libtiff/libtiff/-/commit/49856998c3d82e65444b47bb4fb11b7830a0c2be\n> > Unfortunately the fix is not released yet, but the faulty libtiff is\n> > contained in current buildroot. As a local fix is pretty easy and\n> > without side effects, let's workaround that.\n> > \n> > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > ---\n> >  src/apps/common/dng_writer.cpp | 17 +++++++++++++++++\n> >  1 file changed, 17 insertions(+)\n> > \n> > diff --git a/src/apps/common/dng_writer.cpp b/src/apps/common/dng_writer.cpp\n> > index 103e5c828c4d..7375577e920f 100644\n> > --- a/src/apps/common/dng_writer.cpp\n> > +++ b/src/apps/common/dng_writer.cpp\n> > @@ -541,6 +541,23 @@ int DNGWriter::write(const char *filename, const Camera *camera,\n> >  \n> >  \tTIFFWriteDirectory(tif);\n> >  \n> > +\t/*\n> > +\t * Workaround for a bug introduced in libtiff version 4.5.1 and no fix\n> > +\t * released. In these versions the CFA* tags were missing in the field\n> > +\t * info.\n> > +\t * Introduced by: https://gitlab.com/libtiff/libtiff/-/commit/738e04099b13192bb1f654e74e9b5829313f3161\n> > +\t * Fixed by: https://gitlab.com/libtiff/libtiff/-/commit/49856998c3d82e65444b47bb4fb11b7830a0c2be\n> > +\t */\n> > +\tif (!TIFFFindField(tif, TIFFTAG_CFAREPEATPATTERNDIM, TIFF_ANY)) {\n> > +\t\tstatic const TIFFFieldInfo infos[] = {\n> > +\t\t\t{ TIFFTAG_EP_CFAREPEATPATTERNDIM, 2, 2, TIFF_SHORT, FIELD_CUSTOM,\n> > +\t\t\t  1, 0, const_cast<char *>(\"EP CFARepeatPatternDim\") },\n> > +\t\t\t{ TIFFTAG_EP_CFAPATTERN, -1, -1, TIFF_BYTE, FIELD_CUSTOM,\n> > +\t\t\t  1, 1, const_cast<char *>(\"EP CFAPattern\") },\n> \n> This will fail to compile with libtiff versions older than v4.5.1, where\n> the bug was introduced. TIFFTAG_CFAREPEATPATTERNDIM and\n> TIFFTAG_CFAPATTERN became aliases for TIFFTAG_EP_CFAREPEATPATTERNDIM and\n> TIFFTAG_EP_CFAPATTERN in that version, so I think you can switch to\n> TIFFTAG_CFAREPEATPATTERNDIM and TIFFTAG_CFAPATTERN here. I would also\n> change the description string to drop the \"EP \" prefix.\n\nOh damn, how could I miss that. You are so right.\n\nCheers,\nStefan\n\n> \n> With that,\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> > +\t\t};\n> > +\t\tTIFFMergeFieldInfo(tif, infos, 2);\n> > +\t}\n> > +\n> >  \t/* Create a new IFD for the RAW image. */\n> >  \tconst uint16_t cfaRepeatPatternDim[] = { 2, 2 };\n> >  \tconst uint8_t cfaPlaneColor[] = {\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 8708DBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Jun 2024 08:50:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9921D654AD;\n\tTue, 25 Jun 2024 10:50:13 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D2FC4654A1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Jun 2024 10:50:11 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:ac8e:9f5c:939f:7f08])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3F8B3BEB;\n\tTue, 25 Jun 2024 10:49:49 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"lvpHER6q\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1719305389;\n\tbh=bltH9vw52RU4NLSj0KBR0vE71WLouZ1yn2hkHyVRhME=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=lvpHER6qIC2k6lA22PDjLWTQuj6z36nLz/11w8R2Yvs3CgumpU57XUBAC4E9Ns4aa\n\tBRARrb4Ni8P9SQlxGyOzoqVBwdG5KAeZWezbZrvrjSs6MBRm9f8boMonBhquEBVbqI\n\tRLC98wPOMOpAZQ0Nhj7PfzmZQUj4aCGGxkH4MVxI=","Date":"Tue, 25 Jun 2024 10:50:08 +0200","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH] apps: common: dng_writer: Workaround for \"Unknown tag\n\t33421\" error","Message-ID":"<ysbzjtoy2eihl7utnsoedamckywkbkfazztybwkf62dheil57j@mdopy3l32yft>","References":"<20240625080119.1905870-1-stefan.klug@ideasonboard.com>\n\t<20240625084348.GA30459@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240625084348.GA30459@pendragon.ideasonboard.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]