[libcamera-devel,v1.1] qcam: dng: Make TIFFTAG_CFAPATTERN variable count
diff mbox series

Message ID 20220616084940.63177-1-jeanmichel.hautbois@ideasonboard.com
State Accepted
Commit ae7809307e798ae32f4c978882aca94249ce7fd7
Headers show
Series
  • [libcamera-devel,v1.1] qcam: dng: Make TIFFTAG_CFAPATTERN variable count
Related show

Commit Message

Jean-Michel Hautbois June 16, 2022, 8:49 a.m. UTC
Since libtiff version 20201219, the CFAPATTERN tag is using a variable
count and not the fixed 4 values size.
For reference, the commit introducing this is:

	commit 2eb5a954cb7b7ad61559da00743c4b0e2fce34d0
	Author: Sam Hasinoff <hasinoff@google.com>
	Date:   Sun Mar 8 21:23:16 2020 +0100
	Make TIFFTAG_CFAPATTERN variable count

Add a version check in the DNGWriter::write function when this tag is
written as this breaks the raw capture in qcam.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
---
v1.1: Corrects a typo in the if
        -> /me should really always compile before sending -_-
---
 src/qcam/dng_writer.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart June 16, 2022, 9:06 a.m. UTC | #1
Hi Jean-Michel,

Thank you for the patch.

On Thu, Jun 16, 2022 at 10:49:41AM +0200, Jean-Michel Hautbois via libcamera-devel wrote:
> Since libtiff version 20201219, the CFAPATTERN tag is using a variable
> count and not the fixed 4 values size.
> For reference, the commit introducing this is:
> 
> 	commit 2eb5a954cb7b7ad61559da00743c4b0e2fce34d0
> 	Author: Sam Hasinoff <hasinoff@google.com>
> 	Date:   Sun Mar 8 21:23:16 2020 +0100
> 	Make TIFFTAG_CFAPATTERN variable count
> 
> Add a version check in the DNGWriter::write function when this tag is
> written as this breaks the raw capture in qcam.
> 
> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
> v1.1: Corrects a typo in the if
>         -> /me should really always compile before sending -_-

Sometimes I even think that testing is also a good idea ;-) I have
stopped counting how many times that has happened to me as well. "It's a
simple change, it can't break anything".

> ---
>  src/qcam/dng_writer.cpp | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/qcam/dng_writer.cpp b/src/qcam/dng_writer.cpp
> index 34c8df5a..06491b92 100644
> --- a/src/qcam/dng_writer.cpp
> +++ b/src/qcam/dng_writer.cpp
> @@ -506,7 +506,10 @@ int DNGWriter::write(const char *filename, const Camera *camera,
>  	TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
>  	TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);
>  	TIFFSetField(tif, TIFFTAG_CFAREPEATPATTERNDIM, cfaRepeatPatternDim);
> -	TIFFSetField(tif, TIFFTAG_CFAPATTERN, info->pattern);
> +	if (TIFFLIB_VERSION < 20201219)
> +		TIFFSetField(tif, TIFFTAG_CFAPATTERN, info->pattern);
> +	else
> +		TIFFSetField(tif, TIFFTAG_CFAPATTERN, 4, info->pattern);
>  	TIFFSetField(tif, TIFFTAG_CFAPLANECOLOR, 3, cfaPlaneColor);
>  	TIFFSetField(tif, TIFFTAG_CFALAYOUT, 1);
>

Patch
diff mbox series

diff --git a/src/qcam/dng_writer.cpp b/src/qcam/dng_writer.cpp
index 34c8df5a..06491b92 100644
--- a/src/qcam/dng_writer.cpp
+++ b/src/qcam/dng_writer.cpp
@@ -506,7 +506,10 @@  int DNGWriter::write(const char *filename, const Camera *camera,
 	TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
 	TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);
 	TIFFSetField(tif, TIFFTAG_CFAREPEATPATTERNDIM, cfaRepeatPatternDim);
-	TIFFSetField(tif, TIFFTAG_CFAPATTERN, info->pattern);
+	if (TIFFLIB_VERSION < 20201219)
+		TIFFSetField(tif, TIFFTAG_CFAPATTERN, info->pattern);
+	else
+		TIFFSetField(tif, TIFFTAG_CFAPATTERN, 4, info->pattern);
 	TIFFSetField(tif, TIFFTAG_CFAPLANECOLOR, 3, cfaPlaneColor);
 	TIFFSetField(tif, TIFFTAG_CFALAYOUT, 1);