Skip to content

Commit f85783d

Browse files
author
Cristy
committed
let libheif determine the default CICP parameters
1 parent 09017c4 commit f85783d

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

coders/heic.c

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,11 +1336,6 @@ static MagickBooleanType WriteHEICImage(const ImageInfo *image_info,
13361336
MagickBooleanType
13371337
lossless = image_info->quality >= 100 ? MagickTrue : MagickFalse;
13381338

1339-
#if LIBHEIF_NUMERIC_VERSION >= HEIC_COMPUTE_NUMERIC_VERSION(1,17,0)
1340-
struct heif_color_profile_nclx
1341-
nclx_profile;
1342-
#endif
1343-
13441339
struct heif_encoding_options
13451340
*options;
13461341

@@ -1405,24 +1400,26 @@ static MagickBooleanType WriteHEICImage(const ImageInfo *image_info,
14051400
GeometryInfo
14061401
cicp;
14071402

1408-
/*
1409-
Set BT.709 primaries, sRGB transfer, @ full range.
1410-
*/
1403+
struct heif_color_profile_nclx
1404+
*nclx_profile;
1405+
14111406
SetGeometryInfo(&cicp);
1412-
cicp.rho=1;
1413-
cicp.sigma=13;
1414-
cicp.xi=6;
1415-
cicp.psi=1;
1407+
nclx_profile=heif_nclx_color_profile_alloc();
1408+
cicp.rho=(double) nclx_profile->color_primaries;
1409+
cicp.sigma=(double) nclx_profile->transfer_characteristics;
1410+
cicp.xi=(double) nclx_profile->matrix_coefficients;
1411+
cicp.psi=(double) nclx_profile->full_range_flag;
14161412
(void) ParseGeometry(option,&cicp);
14171413
memset(&nclx_profile,0,sizeof(nclx_profile));
1418-
heif_nclx_color_profile_set_color_primaries(&nclx_profile,
1414+
heif_nclx_color_profile_set_color_primaries(nclx_profile,
14191415
(uint16_t) cicp.rho);
1420-
heif_nclx_color_profile_set_transfer_characteristics(&nclx_profile,
1416+
heif_nclx_color_profile_set_transfer_characteristics(nclx_profile,
14211417
(uint16_t) cicp.sigma);
1422-
heif_nclx_color_profile_set_matrix_coefficients(&nclx_profile,
1418+
heif_nclx_color_profile_set_matrix_coefficients(nclx_profile,
14231419
(uint16_t) cicp.xi);
1424-
nclx_profile.full_range_flag=(uint16_t) cicp.psi;
1425-
heif_image_set_nclx_color_profile(heif_image,&nclx_profile);
1420+
nclx_profile->full_range_flag=(uint16_t) cicp.psi;
1421+
heif_image_set_nclx_color_profile(heif_image,nclx_profile);
1422+
heif_nclx_color_profile_free(nclx_profile);
14261423
}
14271424
#endif
14281425
profile=GetImageProfile(image,"icc");

0 commit comments

Comments
 (0)