From 3aecdcdaa95398999c57b9a379921b52b64280f4 Mon Sep 17 00:00:00 2001
From: Arnav Singh <me@arnavion.dev>
Date: Fri, 26 Apr 2024 08:53:55 -0700
Subject: [PATCH] Don't pass length parameter for
 TIFFSetField(TIFFTAG_CFAREPEATPATTERNDIM)

libtiff broke its API again and now requires the original
three-parameter way of setting TIFFTAG_CFAREPEATPATTERNDIM instead of
the new four-parameter way. It has possibly been like this since v4.5.1.

Megapixels upstream is considering a more permanent way to become immune to
these breakages (switching from libtiff to libdng), but for now this commit
makes the existing release work.

Ref: https://gitlab.com/megapixels-org/Megapixels/-/issues/4
---
 src/process_pipeline.c | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/src/process_pipeline.c b/src/process_pipeline.c
index e6520e6..af6c563 100644
--- a/src/process_pipeline.c
+++ b/src/process_pipeline.c
@@ -693,21 +693,12 @@ process_image_for_capture(const uint8_t *image, int count)
         TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
         TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
 
-#if (TIFFLIB_VERSION > 20230000)
-        static const short cfapatterndim[] = { 2, 2 };
-        TIFFSetField(tif, TIFFTAG_CFAREPEATPATTERNDIM, 2, cfapatterndim);
-        TIFFSetField(tif,
-                     DNGTAG_CFAPATTERN,
-                     4,
-                     mp_pixel_format_cfa_pattern(mode.pixel_format));
-#else
         static const short cfapatterndim[] = { 2, 2 };
         TIFFSetField(tif, TIFFTAG_CFAREPEATPATTERNDIM, cfapatterndim);
         TIFFSetField(tif,
                      DNGTAG_CFAPATTERN,
                      4,
                      mp_pixel_format_cfa_pattern(mode.pixel_format));
-#endif
 
         printf("TIFF version %d\n", TIFFLIB_VERSION);
         int whitelevel = camera->whitelevel;
-- 
2.44.0

