From edd1de7a9ed1b5ac367796d2910beee3a4f5839c Mon Sep 17 00:00:00 2001 From: Martijn Braam Date: Tue, 22 Dec 2020 17:13:36 +0100 Subject: [PATCH] Add meson option for the tiff cfa pattern bug --- meson.build | 5 +++++ meson_options.txt | 2 ++ process_pipeline.c | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 meson_options.txt diff --git a/meson.build b/meson.build index b088ad3..0c324bf 100644 --- a/meson.build +++ b/meson.build @@ -21,6 +21,11 @@ if get_option('buildtype') == 'debug' add_global_arguments('-DDEBUG', language: 'c') endif +# Workaround for libtiff having ABI changes but not changing the internal version number +if get_option('tiffcfapattern') + add_global_arguments('-DLIBTIFF_CFA_PATTERN', language: 'c') +endif + executable('megapixels', 'main.c', 'ini.c', 'quickpreview.c', 'camera.c', 'device.c', 'pipeline.c', 'camera_config.c', 'io_pipeline.c', 'process_pipeline.c', 'matrix.c', resources, dependencies : [gtkdep, libm, tiff, threads], install : true) install_data(['data/org.postmarketos.Megapixels.desktop'], diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..849066b --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,2 @@ +option('tiffcfapattern', type: 'boolean', value: false) + diff --git a/process_pipeline.c b/process_pipeline.c index 7850c14..a706176 100644 --- a/process_pipeline.c +++ b/process_pipeline.c @@ -236,11 +236,12 @@ process_image_for_capture(const MPImage *image, int count) TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); static const short cfapatterndim[] = { 2, 2 }; TIFFSetField(tif, TIFFTAG_CFAREPEATPATTERNDIM, cfapatterndim); -#if (TIFFLIB_VERSION < 20201219) +#if (TIFFLIB_VERSION < 20201219) && !LIBTIFF_CFA_PATTERN TIFFSetField(tif, TIFFTAG_CFAPATTERN, "\002\001\001\000"); // BGGR #else TIFFSetField(tif, TIFFTAG_CFAPATTERN, 4, "\002\001\001\000"); // BGGR #endif + printf("TIFF version %d\n", TIFFLIB_VERSION); if (camera->whitelevel) { TIFFSetField(tif, TIFFTAG_WHITELEVEL, 1, &camera->whitelevel); }