File fix-compat-break-with-libraw-pr3143.patch of Package OpenImageIO
From 650772433010b5889e6d2694137cace2567ad487 Mon Sep 17 00:00:00 2001
From: Larry Gritz <lg@larrygritz.com>
Date: Sat, 23 Oct 2021 12:58:13 -0700
Subject: [PATCH] raw: Fix compat break in their 202110 snapshot (#3143)
---
src/raw.imageio/rawinput.cpp | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
--- a/src/raw.imageio/rawinput.cpp
+++ b/src/raw.imageio/rawinput.cpp
@@ -29,9 +29,6 @@ template<class T> using auto_ptr = uniqu
}
#endif
-#include <libraw/libraw.h>
-#include <libraw/libraw_version.h>
-
// This plugin utilises LibRaw:
// http://www.libraw.org/
@@ -40,6 +37,18 @@ template<class T> using auto_ptr = uniqu
// Example raw images from many camera models:
// https://www.rawsamples.ch
+#include <libraw/libraw.h>
+#include <libraw/libraw_version.h>
+
+#if LIBRAW_VERSION < LIBRAW_MAKE_VERSION(0, 15, 0)
+# error "OpenImageIO does not support such an old LibRaw"
+#endif
+
+// Some structure layouts changed mid-release on this snapshot
+#define LIBRAW_VERSION_AT_LEAST_SNAPSHOT_202110 \
+ (LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 21, 0) \
+ && LIBRAW_SHLIB_CURRENT >= 22)
+
OIIO_PLUGIN_NAMESPACE_BEGIN
@@ -829,6 +838,16 @@ RawInput::get_makernotes_canon()
MAKERF(ContinuousDrive);
MAKER(SensorWidth, 0);
MAKER(SensorHeight, 0);
+# if LIBRAW_VERSION_AT_LEAST_SNAPSHOT_202110
+ add(m_make, "SensorLeftBorder", mn.DefaultCropAbsolute.l, false, 0);
+ add(m_make, "SensorTopBorder", mn.DefaultCropAbsolute.t, false, 0);
+ add(m_make, "SensorRightBorder", mn.DefaultCropAbsolute.r, false, 0);
+ add(m_make, "SensorBottomBorder", mn.DefaultCropAbsolute.b, false, 0);
+ add(m_make, "BlackMaskLeftBorder", mn.LeftOpticalBlack.l, false, 0);
+ add(m_make, "BlackMaskTopBorder", mn.LeftOpticalBlack.t, false, 0);
+ add(m_make, "BlackMaskRightBorder", mn.LeftOpticalBlack.r, false, 0);
+ add(m_make, "BlackMaskBottomBorder", mn.LeftOpticalBlack.b, false, 0);
+# else
MAKER(SensorLeftBorder, 0);
MAKER(SensorTopBorder, 0);
MAKER(SensorRightBorder, 0);
@@ -837,6 +856,7 @@ RawInput::get_makernotes_canon()
MAKER(BlackMaskTopBorder, 0);
MAKER(BlackMaskRightBorder, 0);
MAKER(BlackMaskBottomBorder, 0);
+# endif
#endif
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 19, 0)
// Extra added with libraw 0.19: