Skip to content

Commit 83a90bd

Browse files
chenrui333lgritz
andcommitted
build: Fixes to build against libheif 1.20 (#4822)
Seeing build failures when building against libheif 1.20: ``` /private/tmp/openimageio-20250701-18561-96sl0/OpenImageIO-3.0.8.0/src/heif.imageio/heifinput.cpp:390:37: error: no matching member function for call to 'get_plane' 390 | const uint8_t* hdata = m_himage.get_plane(heif_channel_interleaved, | ~~~~~~~~~^~~~~~~~~ /opt/homebrew/include/libheif/heif_cxx.h:909:32: note: candidate function not viable: no known conversion from 'int *' to 'size_t *' (aka 'unsigned long *') for 2nd argument 909 | inline const uint8_t* Image::get_plane(enum heif_channel channel, size_t* out_stride) const noexcept | ^ ~~~~~~~~~~~~~~~~~~ /opt/homebrew/include/libheif/heif_cxx.h:914:26: note: candidate function not viable: no known conversion from 'int *' to 'size_t *' (aka 'unsigned long *') for 2nd argument 914 | inline uint8_t* Image::get_plane(enum heif_channel channel, size_t* out_stride) noexcept | ^ ~~~~~~~~~~~~~~~~~~ 1 error generated. ``` relates to Homebrew/homebrew-core#228740 Starting with 1.20, libheif changed the type of a stride parameter. --------- Signed-off-by: Rui Chen <[email protected]> Signed-off-by: Larry Gritz <[email protected]> Co-authored-by: Larry Gritz <[email protected]>
1 parent ba5a430 commit 83a90bd

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/heif.imageio/heifinput.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,11 @@ HeifInput::read_native_scanline(int subimage, int miplevel, int y, int /*z*/,
385385
return false;
386386
if (y < 0 || y >= m_spec.height) // out of range scanline
387387
return false;
388-
389-
int ystride = 0;
388+
#if LIBHEIF_NUMERIC_VERSION >= MAKE_LIBHEIF_VERSION(1, 20, 0, 0)
389+
size_t ystride = 0;
390+
#else
391+
int ystride = 0;
392+
#endif
390393
const uint8_t* hdata = m_himage.get_plane(heif_channel_interleaved,
391394
&ystride);
392395
if (!hdata) {

src/heif.imageio/heifoutput.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99

1010
#include <libheif/heif_cxx.h>
1111

12+
#define MAKE_LIBHEIF_VERSION(a, b, c, d) \
13+
(((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
14+
15+
#if LIBHEIF_NUMERIC_VERSION >= MAKE_LIBHEIF_VERSION(1, 17, 0, 0)
16+
# include <libheif/heif_properties.h>
17+
#endif
18+
1219

1320
OIIO_PLUGIN_NAMESPACE_BEGIN
1421

@@ -142,8 +149,12 @@ bool
142149
HeifOutput::write_scanline(int y, int /*z*/, TypeDesc format, const void* data,
143150
stride_t xstride)
144151
{
145-
data = to_native_scanline(format, data, xstride, scratch);
146-
int hystride = 0;
152+
data = to_native_scanline(format, data, xstride, scratch);
153+
#if LIBHEIF_NUMERIC_VERSION >= MAKE_LIBHEIF_VERSION(1, 20, 0, 0)
154+
size_t hystride = 0;
155+
#else
156+
int hystride = 0;
157+
#endif
147158
uint8_t* hdata = m_himage.get_plane(heif_channel_interleaved, &hystride);
148159
hdata += hystride * (y - m_spec.y);
149160
memcpy(hdata, data, hystride);

0 commit comments

Comments
 (0)