Skip to content

Commit 81cb1a4

Browse files
authored
build(deps): Raise minimum libraw to 0.18 (#3921)
Rationale: * LibRaw 0.18 was released in last 2016, so we are stil supporting all libraw from up to 6 years back. * LibRaw 0.18 is necessary for ACES, plus it improves a lot of metadata handling. * LibRaw 0.20 is the minimum that can be used when compiling with C++17, and we will almost certainly move to C++17 as a minimum in OIIO 2.6, so it seems like LibRaw 0.18 is reasonable minimum for the upcmoming 2.5. Remove some cruft that's no longer necessary if we drop support for 0.15-0.17. Signed-off-by: Larry Gritz <[email protected]>
1 parent 004cbb0 commit 81cb1a4

File tree

4 files changed

+30
-88
lines changed

4 files changed

+30
-88
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Release 2.5 (summer 2023?) -- compared to 2.4
22
-------------------------------------------------
33
### New minimum dependencies and compatibility changes:
4+
* LibRaw: minimum has ben raised from 0.15 to 0.18. (2.5.2.1)
45

56
### ⛰️ New features and public API changes:
67
* TextureSystem color management: #3761 (2.5.1.0)

INSTALL.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**.
4040
not support Python < 3.6.)
4141
* NumPy
4242
* If you want support for camera "RAW" formats:
43-
* LibRaw >= 0.15 (tested 0.15 - 0.21.1; LibRaw >= 0.18 is necessary for
44-
ACES support and much better recognition of camera metadata; if
43+
* LibRaw >= 0.18 (tested though 0.21.1; if
4544
building with C++17 or higher, LibRaw >= 0.20 is necessary)
4645
* If you want support for a wide variety of video formats:
4746
* ffmpeg >= 3.0 (tested through 6.0)

src/cmake/externalpackages.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,7 @@ if (APPLE AND LIBHEIF_VERSION VERSION_GREATER_EQUAL 1.10 AND LIBHEIF_VERSION VER
216216
endif ()
217217

218218
checked_find_package (LibRaw
219-
RECOMMEND_MIN 0.18
220-
RECOMMEND_MIN_REASON "for ACES support and better camera metadata"
219+
VERSION_MIN 0.18
221220
PRINT LibRaw_r_LIBRARIES)
222221
if (LibRaw_FOUND AND LibRaw_VERSION VERSION_LESS 0.20 AND CMAKE_CXX_STANDARD VERSION_GREATER_EQUAL 17)
223222
message (STATUS "${ColorYellow}WARNING When building for C++17, LibRaw should be 0.20 or higher (found ${LibRaw_VERSION}). You may get errors, depending on the compiler.${ColorReset}")

src/raw.imageio/rawinput.cpp

Lines changed: 27 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ template<class T> using auto_ptr = unique_ptr<T>;
4242
#include <libraw/libraw.h>
4343
#include <libraw/libraw_version.h>
4444

45-
#if LIBRAW_VERSION < LIBRAW_MAKE_VERSION(0, 15, 0)
45+
#if LIBRAW_VERSION < LIBRAW_MAKE_VERSION(0, 18, 0)
4646
# error "OpenImageIO does not support such an old LibRaw"
4747
#endif
4848

@@ -284,7 +284,6 @@ RawInput::open(const std::string& name, ImageSpec& newspec)
284284

285285

286286

287-
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 17, 0)
288287
static void
289288
exif_parser_cb(ImageSpec* spec, int tag, int tifftype, int len,
290289
unsigned int byteorder, LibRaw_abstract_datastream* ifp)
@@ -359,7 +358,6 @@ exif_parser_cb(ImageSpec* spec, int tag, int tifftype, int len,
359358
// Strutil::fprintf (std::cerr, "RAW metadata NOT HANDLED: tag=%s: tifftype=%d,len=%d (%s), byteorder=0x%x\n",
360359
// taginfo->name, tifftype, len, type, byteorder);
361360
}
362-
#endif
363361

364362

365363

@@ -401,10 +399,8 @@ RawInput::open_raw(bool unpack, const std::string& name,
401399

402400
// Temp spec for exif parser callback to dump into
403401
ImageSpec exifspec;
404-
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 17, 0)
405402
m_processor->set_exifparser_handler((exif_parser_callback)exif_parser_cb,
406403
&exifspec);
407-
#endif
408404

409405
// Force flip value if needed. If user_flip is -1, libraw ignores it
410406
m_processor->imgdata.params.user_flip
@@ -587,26 +583,16 @@ RawInput::open_raw(bool unpack, const std::string& name,
587583
m_processor->imgdata.params.gamm[0] = 1.0;
588584
m_processor->imgdata.params.gamm[1] = 1.0;
589585
} else if (Strutil::iequals(cs, "ACES")) {
590-
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 18, 0)
591586
// ACES linear
592587
m_processor->imgdata.params.output_color = 6;
593588
m_processor->imgdata.params.gamm[0] = 1.0;
594589
m_processor->imgdata.params.gamm[1] = 1.0;
595-
#else
596-
errorfmt("raw:ColorSpace value of \"{}\" is not supported by libRaw {}",
597-
cs, LIBRAW_VERSION_STR);
598-
return false;
599-
#endif
600-
} else if (Strutil::iequals(cs, "DCI-P3")) {
601590
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 21, 0)
602-
// ACES linear
591+
} else if (Strutil::iequals(cs, "DCI-P3")) {
592+
// DCI-P3
603593
m_processor->imgdata.params.output_color = 7;
604594
m_processor->imgdata.params.gamm[0] = 1.0;
605595
m_processor->imgdata.params.gamm[1] = 1.0;
606-
#else
607-
errorfmt("raw:ColorSpace value of \"{}\" is not supported by libRaw {}",
608-
cs, LIBRAW_VERSION_STR);
609-
return false;
610596
#endif
611597
} else if (Strutil::iequals(cs, "Rec2020")) {
612598
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 21, 0)
@@ -648,21 +634,8 @@ RawInput::open_raw(bool unpack, const std::string& name,
648634
std::string demosaic = config.get_string_attribute("raw:Demosaic");
649635
if (demosaic.size()) {
650636
static const char* demosaic_algs[]
651-
= { "linear",
652-
"VNG",
653-
"PPG",
654-
"AHD",
655-
"DCB",
656-
"AHD-Mod",
657-
"AFD",
658-
"VCD",
659-
"Mixed",
660-
"LMMSE",
661-
"AMaZE",
662-
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 16, 0)
663-
"DHT",
664-
"AAHD",
665-
#endif
637+
= { "linear", "VNG", "PPG", "AHD", "DCB", "AHD-Mod", "AFD", "VCD",
638+
"Mixed", "LMMSE", "AMaZE", "DHT", "AAHD",
666639
// Future demosaicing algorithms should go here
667640
NULL };
668641
size_t d;
@@ -672,17 +645,6 @@ RawInput::open_raw(bool unpack, const std::string& name,
672645
if (demosaic_algs[d])
673646
m_processor->imgdata.params.user_qual = d;
674647
else if (Strutil::iequals(demosaic, "none")) {
675-
#ifdef LIBRAW_DECODER_FLATFIELD
676-
// See if we can access the Bayer patterned data for this raw file
677-
libraw_decoder_info_t decoder_info;
678-
m_processor->get_decoder_info(&decoder_info);
679-
if (!(decoder_info.decoder_flags & LIBRAW_DECODER_FLATFIELD)) {
680-
errorf("Unable to extract unbayered data from file \"%s\"",
681-
name);
682-
return false;
683-
}
684-
685-
#endif
686648
// User has selected no demosaicing, so no processing needs to be done
687649
m_process = false;
688650

@@ -853,12 +815,9 @@ RawInput::open_raw(bool unpack, const std::string& name,
853815
}
854816
if (idata.model[0])
855817
m_spec.attribute("Model", idata.model);
856-
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 17, 0)
857818
if (idata.software[0])
858819
m_spec.attribute("Software", idata.software);
859-
else
860-
#endif
861-
if (color.model2[0])
820+
else if (color.model2[0])
862821
m_spec.attribute("Software", color.model2);
863822

864823
// FIXME: idata. dng_version, is_foveon, colors, filters, cdesc
@@ -885,15 +844,14 @@ RawInput::open_raw(bool unpack, const std::string& name,
885844
m_spec.attribute("ImageDescription", other.desc);
886845
if (other.artist[0])
887846
m_spec.attribute("Artist", other.artist);
888-
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 17, 0)
889847
if (other.parsed_gps.gpsparsed) {
890848
add("GPS", "Latitude", other.parsed_gps.latitude, false, 0.0f);
891-
# if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 20, 0)
849+
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 20, 0)
892850
add("GPS", "Longitude", other.parsed_gps.longitude, false, 0.0f);
893-
# else
851+
#else
894852
add("GPS", "Longitude", other.parsed_gps.longtitude, false,
895853
0.0f); // N.B. wrong spelling!
896-
# endif
854+
#endif
897855
add("GPS", "TimeStamp", other.parsed_gps.gpstimestamp, false, 0.0f);
898856
add("GPS", "Altitude", other.parsed_gps.altitude, false, 0.0f);
899857
add("GPS", "LatitudeRef", string_view(&other.parsed_gps.latref, 1),
@@ -905,7 +863,6 @@ RawInput::open_raw(bool unpack, const std::string& name,
905863
add("GPS", "Status", string_view(&other.parsed_gps.gpsstatus, 1),
906864
false);
907865
}
908-
#endif
909866
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 20, 0)
910867
const libraw_makernotes_t& makernotes(m_processor->imgdata.makernotes);
911868
const libraw_metadata_common_t& common(makernotes.common);
@@ -1006,7 +963,6 @@ RawInput::get_makernotes()
1006963
void
1007964
RawInput::get_makernotes_canon()
1008965
{
1009-
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 18, 0)
1010966
auto const& mn(m_processor->imgdata.makernotes.canon);
1011967
// MAKER (CanonColorDataVer, 0);
1012968
// MAKER (CanonColorDataSubVer, 0);
@@ -1020,7 +976,7 @@ RawInput::get_makernotes_canon()
1020976
MAKERF(ExposureMode);
1021977
MAKERF(AESetting);
1022978
MAKERF(ImageStabilization);
1023-
# if LIBRAW_VERSION < LIBRAW_MAKE_VERSION(0, 21, 0)
979+
#if LIBRAW_VERSION < LIBRAW_MAKE_VERSION(0, 21, 0)
1024980
MAKERF(HighlightTonePriority);
1025981
MAKERF(FocusMode);
1026982
MAKER(AFPoint, 0);
@@ -1042,7 +998,7 @@ RawInput::get_makernotes_canon()
1042998
// short AFPointsSelected[4];
1043999
// ushort PrimaryAFPoint;
10441000
}
1045-
# endif
1001+
#endif
10461002
MAKERF(FlashMode);
10471003
MAKERF(FlashActivity);
10481004
MAKER(FlashBits, 0);
@@ -1052,7 +1008,7 @@ RawInput::get_makernotes_canon()
10521008
MAKERF(ContinuousDrive);
10531009
MAKER(SensorWidth, 0);
10541010
MAKER(SensorHeight, 0);
1055-
# if LIBRAW_VERSION_AT_LEAST_SNAPSHOT_202110
1011+
#if LIBRAW_VERSION_AT_LEAST_SNAPSHOT_202110
10561012
add(m_make, "SensorLeftBorder", mn.DefaultCropAbsolute.l, false, 0);
10571013
add(m_make, "SensorTopBorder", mn.DefaultCropAbsolute.t, false, 0);
10581014
add(m_make, "SensorRightBorder", mn.DefaultCropAbsolute.r, false, 0);
@@ -1061,7 +1017,7 @@ RawInput::get_makernotes_canon()
10611017
add(m_make, "BlackMaskTopBorder", mn.LeftOpticalBlack.t, false, 0);
10621018
add(m_make, "BlackMaskRightBorder", mn.LeftOpticalBlack.r, false, 0);
10631019
add(m_make, "BlackMaskBottomBorder", mn.LeftOpticalBlack.b, false, 0);
1064-
# else
1020+
#else
10651021
MAKER(SensorLeftBorder, 0);
10661022
MAKER(SensorTopBorder, 0);
10671023
MAKER(SensorRightBorder, 0);
@@ -1070,7 +1026,6 @@ RawInput::get_makernotes_canon()
10701026
MAKER(BlackMaskTopBorder, 0);
10711027
MAKER(BlackMaskRightBorder, 0);
10721028
MAKER(BlackMaskBottomBorder, 0);
1073-
# endif
10741029
#endif
10751030
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 19, 0)
10761031
// Extra added with libraw 0.19:
@@ -1150,15 +1105,14 @@ RawInput::get_makernotes_nikon()
11501105
void
11511106
RawInput::get_makernotes_olympus()
11521107
{
1153-
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 18, 0)
11541108
auto const& mn(m_processor->imgdata.makernotes.olympus);
1155-
# if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 20, 0)
1109+
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 20, 0)
11561110
MAKERF(SensorCalibration);
1157-
# else
1111+
#else
11581112
MAKERF(OlympusCropID);
11591113
MAKERF(OlympusFrame); /* upper left XY, lower right XY */
11601114
MAKERF(OlympusSensorCalibration);
1161-
# endif
1115+
#endif
11621116
MAKERF(FocusMode);
11631117
MAKERF(AutoFocus);
11641118
MAKERF(AFPoint);
@@ -1167,7 +1121,6 @@ RawInput::get_makernotes_olympus()
11671121
MAKERF(AFResult);
11681122
// MAKERF(ImageStabilization); Removed after 0.19
11691123
MAKERF(ColorSpace);
1170-
#endif
11711124
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 19, 0)
11721125
MAKERF(AFFineTune);
11731126
if (mn.AFFineTune)
@@ -1231,24 +1184,23 @@ RawInput::get_makernotes_kodak()
12311184
void
12321185
RawInput::get_makernotes_fuji()
12331186
{
1234-
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 18, 0)
12351187
auto const& mn(m_processor->imgdata.makernotes.fuji);
12361188

1237-
# if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 20, 0)
1189+
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 20, 0)
12381190
add(m_make, "ExpoMidPointShift", mn.ExpoMidPointShift);
12391191
add(m_make, "DynamicRange", mn.DynamicRange);
12401192
add(m_make, "FilmMode", mn.FilmMode);
12411193
add(m_make, "DynamicRangeSetting", mn.DynamicRangeSetting);
12421194
add(m_make, "DevelopmentDynamicRange", mn.DevelopmentDynamicRange);
12431195
add(m_make, "AutoDynamicRange", mn.AutoDynamicRange);
1244-
# else
1196+
#else
12451197
add(m_make, "ExpoMidPointShift", mn.FujiExpoMidPointShift);
12461198
add(m_make, "DynamicRange", mn.FujiDynamicRange);
12471199
add(m_make, "FilmMode", mn.FujiFilmMode);
12481200
add(m_make, "DynamicRangeSetting", mn.FujiDynamicRangeSetting);
12491201
add(m_make, "DevelopmentDynamicRange", mn.FujiDevelopmentDynamicRange);
12501202
add(m_make, "AutoDynamicRange", mn.FujiAutoDynamicRange);
1251-
# endif
1203+
#endif
12521204

12531205
MAKERF(FocusMode);
12541206
MAKERF(AFMode);
@@ -1260,11 +1212,10 @@ RawInput::get_makernotes_fuji()
12601212
MAKERF(ExrMode);
12611213
MAKERF(Macro);
12621214
MAKERF(Rating);
1263-
# if LIBRAW_VERSION < LIBRAW_MAKE_VERSION(0, 21, 0)
1215+
#if LIBRAW_VERSION < LIBRAW_MAKE_VERSION(0, 21, 0)
12641216
MAKERF(FrameRate);
12651217
MAKERF(FrameWidth);
12661218
MAKERF(FrameHeight);
1267-
# endif
12681219
#endif
12691220
}
12701221

@@ -1273,13 +1224,11 @@ RawInput::get_makernotes_fuji()
12731224
void
12741225
RawInput::get_makernotes_sony()
12751226
{
1276-
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 18, 0)
12771227
auto const& mn(m_processor->imgdata.makernotes.sony);
1278-
#endif
12791228

12801229
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 20, 0)
12811230
MAKERF(CameraType);
1282-
#elif LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 18, 0)
1231+
#else
12831232
MAKERF(SonyCameraType);
12841233
#endif
12851234

@@ -1322,7 +1271,6 @@ RawInput::get_makernotes_sony()
13221271
void
13231272
RawInput::get_lensinfo()
13241273
{
1325-
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 18, 0)
13261274
{
13271275
auto const& mn(m_processor->imgdata.lens);
13281276
MAKER(MinFocal, 0.0f);
@@ -1370,29 +1318,29 @@ RawInput::get_lensinfo()
13701318
MAKER(Adapter, 0);
13711319
MAKER(AttachmentID, 0ULL);
13721320
MAKER(Attachment, 0);
1373-
# if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 20, 0)
1321+
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 20, 0)
13741322
MAKER(FocalUnits, 0);
1375-
# else
1323+
#else
13761324
MAKER(CanonFocalUnits, 0);
1377-
# endif
1325+
#endif
13781326
MAKER(FocalLengthIn35mmFormat, 0.0f);
13791327
}
13801328

13811329
if (Strutil::iequals(m_make, "Nikon")) {
13821330
auto const& mn(m_processor->imgdata.lens.nikon);
1383-
# if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 20, 0)
1331+
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 20, 0)
13841332
add(m_make, "EffectiveMaxAp", mn.EffectiveMaxAp);
13851333
add(m_make, "LensIDNumber", mn.LensIDNumber);
13861334
add(m_make, "LensFStops", mn.LensFStops);
13871335
add(m_make, "MCUVersion", mn.MCUVersion);
13881336
add(m_make, "LensType", mn.LensType);
1389-
# else
1337+
#else
13901338
add(m_make, "EffectiveMaxAp", mn.NikonEffectiveMaxAp);
13911339
add(m_make, "LensIDNumber", mn.NikonLensIDNumber);
13921340
add(m_make, "LensFStops", mn.NikonLensFStops);
13931341
add(m_make, "MCUVersion", mn.NikonMCUVersion);
13941342
add(m_make, "LensType", mn.NikonLensType);
1395-
# endif
1343+
#endif
13961344
}
13971345
if (Strutil::iequals(m_make, "DNG")) {
13981346
auto const& mn(m_processor->imgdata.lens.dng);
@@ -1401,15 +1349,13 @@ RawInput::get_lensinfo()
14011349
MAKER(MaxFocal, 0.0f);
14021350
MAKER(MinFocal, 0.0f);
14031351
}
1404-
#endif
14051352
}
14061353

14071354

14081355

14091356
void
14101357
RawInput::get_shootinginfo()
14111358
{
1412-
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 18, 0)
14131359
auto const& mn(m_processor->imgdata.shootinginfo);
14141360
MAKER(DriveMode, -1);
14151361
MAKER(FocusMode, -1);
@@ -1419,15 +1365,13 @@ RawInput::get_shootinginfo()
14191365
MAKERF(ImageStabilization);
14201366
MAKER(BodySerial, 0);
14211367
MAKER(InternalBodySerial, 0);
1422-
#endif
14231368
}
14241369

14251370

14261371

14271372
void
14281373
RawInput::get_colorinfo()
14291374
{
1430-
#if LIBRAW_VERSION >= LIBRAW_MAKE_VERSION(0, 18, 0)
14311375
add("raw", "pre_mul",
14321376
cspan<float>(&(m_processor->imgdata.color.pre_mul[0]),
14331377
&(m_processor->imgdata.color.pre_mul[4])),
@@ -1444,7 +1388,6 @@ RawInput::get_colorinfo()
14441388
cspan<float>(&(m_processor->imgdata.color.cam_xyz[0][0]),
14451389
&(m_processor->imgdata.color.cam_xyz[3][3])),
14461390
false, 0.f);
1447-
#endif
14481391
}
14491392

14501393

0 commit comments

Comments
 (0)