Skip to content

Commit c3ccc9e

Browse files
authored
deps: libheif 1.21 support (AcademySoftwareFoundation#4992)
Starting with 1.21, libheif seems to change behavior: When no CICP metadata is present, libheif now returns 2,2,2 (all unspecified) on read. OIIO convention, though, is to not set the attribute if valid CICP data is not in the file. --------- Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent 312793a commit c3ccc9e

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**.
6464
* giflib >= 5.0 (tested through 5.2.2)
6565
* If you want support for HEIF/HEIC or AVIF images:
6666
* libheif >= 1.11 (1.16 required for correct orientation support,
67-
tested through 1.20.2)
67+
tested through 1.21.1)
6868
* libheif must be built with an AV1 encoder/decoder for AVIF support.
6969
* If you want support for DICOM medical image files:
7070
* DCMTK >= 3.6.1 (tested through 3.6.9)

src/heif.imageio/heifinput.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,14 @@ HeifInput::seek_subimage(int subimage, int miplevel)
287287
m_ihandle.get_raw_image_handle(), &nclx);
288288

289289
if (nclx) {
290-
if (err.code == heif_error_Ok) {
290+
// When CICP metadata is not present in the file, libheif returns
291+
// unspecified since v1.21. Ignore it then.
292+
if (err.code == heif_error_Ok
293+
&& !(nclx->color_primaries == heif_color_primaries_unspecified
294+
&& nclx->transfer_characteristics
295+
== heif_transfer_characteristic_unspecified
296+
&& nclx->matrix_coefficients
297+
== heif_matrix_coefficients_unspecified)) {
291298
const int cicp[4] = { int(nclx->color_primaries),
292299
int(nclx->transfer_characteristics),
293300
int(nclx->matrix_coefficients),

0 commit comments

Comments
 (0)