From fc20a7a654d23ed24711760839c4879e004a2b76 Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Fri, 12 Jun 2020 20:20:25 +0100 Subject: [PATCH] Add bt709 ICC profile, use for heif 'nclx' --- libvips/colour/profiles.c | 58 ++++++++++++++++++++++++++++ libvips/colour/profiles/Makefile.am | 1 + libvips/colour/profiles/bt709.icm | Bin 0 -> 596 bytes libvips/foreign/heifload.c | 12 +++++- 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 libvips/colour/profiles/bt709.icm diff --git a/libvips/colour/profiles.c b/libvips/colour/profiles.c index 8a4ca0c0..edc52080 100644 --- a/libvips/colour/profiles.c +++ b/libvips/colour/profiles.c @@ -2,6 +2,63 @@ #include "profiles.h" +static VipsProfileFallback vips__profile_fallback_bt709 = { + "bt709", + 596, + { + 0x00, 0x00, 0x02, 0x54, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x6D, 0x6E, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5A, 0x20, + 0x07, 0xDB, 0x00, 0x02, 0x00, 0x10, 0x00, 0x12, 0x00, 0x1D, 0x00, 0x21, + 0x61, 0x63, 0x73, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF6, 0xD6, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xD3, 0x2D, 0x00, 0x00, 0x00, 0x00, + 0x6F, 0x72, 0x3A, 0x61, 0x57, 0x09, 0xAE, 0xA0, 0xE1, 0x65, 0x88, 0x4C, + 0x20, 0x1D, 0x80, 0xE4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, + 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x79, + 0x62, 0x58, 0x59, 0x5A, 0x00, 0x00, 0x01, 0x84, 0x00, 0x00, 0x00, 0x14, + 0x62, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0x98, 0x00, 0x00, 0x00, 0x10, + 0x67, 0x58, 0x59, 0x5A, 0x00, 0x00, 0x01, 0xA8, 0x00, 0x00, 0x00, 0x14, + 0x67, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0x98, 0x00, 0x00, 0x00, 0x10, + 0x72, 0x58, 0x59, 0x5A, 0x00, 0x00, 0x01, 0xBC, 0x00, 0x00, 0x00, 0x14, + 0x72, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0x98, 0x00, 0x00, 0x00, 0x10, + 0x74, 0x65, 0x63, 0x68, 0x00, 0x00, 0x01, 0xD0, 0x00, 0x00, 0x00, 0x0C, + 0x77, 0x74, 0x70, 0x74, 0x00, 0x00, 0x01, 0xDC, 0x00, 0x00, 0x00, 0x14, + 0x63, 0x70, 0x72, 0x74, 0x00, 0x00, 0x01, 0xF0, 0x00, 0x00, 0x00, 0x37, + 0x63, 0x68, 0x61, 0x64, 0x00, 0x00, 0x02, 0x28, 0x00, 0x00, 0x00, 0x2C, + 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, + 0x49, 0x54, 0x55, 0x2D, 0x52, 0x20, 0x42, 0x54, 0x2E, 0x37, 0x30, 0x39, + 0x20, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6E, 0x63, 0x65, 0x20, 0x44, + 0x69, 0x73, 0x70, 0x6C, 0x61, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x58, 0x59, 0x5A, 0x20, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x24, 0xA0, 0x00, 0x00, 0x0F, 0x84, 0x00, 0x00, 0xB6, 0xCF, + 0x63, 0x75, 0x72, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x02, 0x66, 0x00, 0x00, 0x58, 0x59, 0x5A, 0x20, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x62, 0x99, 0x00, 0x00, 0xB7, 0x85, 0x00, 0x00, 0x18, 0xDA, + 0x58, 0x59, 0x5A, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0xA2, + 0x00, 0x00, 0x38, 0xF5, 0x00, 0x00, 0x03, 0x90, 0x73, 0x69, 0x67, 0x20, + 0x00, 0x00, 0x00, 0x00, 0x43, 0x52, 0x54, 0x20, 0x58, 0x59, 0x5A, 0x20, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF6, 0xD6, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0xD3, 0x2D, 0x74, 0x65, 0x78, 0x74, 0x00, 0x00, 0x00, 0x00, + 0x43, 0x6F, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x49, 0x6E, + 0x74, 0x65, 0x72, 0x6E, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x61, 0x6C, 0x20, + 0x43, 0x6F, 0x6C, 0x6F, 0x72, 0x20, 0x43, 0x6F, 0x6E, 0x73, 0x6F, 0x72, + 0x74, 0x69, 0x75, 0x6D, 0x2C, 0x20, 0x32, 0x30, 0x31, 0x31, 0x00, 0x00, + 0x73, 0x66, 0x33, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0C, 0x44, + 0x00, 0x00, 0x05, 0xDF, 0xFF, 0xFF, 0xF3, 0x26, 0x00, 0x00, 0x07, 0x94, + 0x00, 0x00, 0xFD, 0x8F, 0xFF, 0xFF, 0xFB, 0xA1, 0xFF, 0xFF, 0xFD, 0xA2, + 0x00, 0x00, 0x03, 0xDB, 0x00, 0x00, 0xC0, 0x75, + } +}; + static VipsProfileFallback vips__profile_fallback_cmyk = { "cmyk", 961644, @@ -80731,6 +80788,7 @@ static VipsProfileFallback vips__profile_fallback_sRGB = { }; VipsProfileFallback *vips__profile_fallback_table[] = { + &vips__profile_fallback_bt709, &vips__profile_fallback_cmyk, &vips__profile_fallback_sRGB, NULL diff --git a/libvips/colour/profiles/Makefile.am b/libvips/colour/profiles/Makefile.am index fc8f9734..a53d0104 100644 --- a/libvips/colour/profiles/Makefile.am +++ b/libvips/colour/profiles/Makefile.am @@ -1,3 +1,4 @@ EXTRA_DIST = \ + bt709.icm \ cmyk.icm \ sRGB.icm diff --git a/libvips/colour/profiles/bt709.icm b/libvips/colour/profiles/bt709.icm new file mode 100644 index 0000000000000000000000000000000000000000..0b6669ff2c5447c533eb9c9a556b2e43522a7f76 GIT binary patch literal 596 zcmZQzUTKTzYP=;U=U)EWl&5^E-nD6K?95k{K(e4BycKq&xT C4Q(|5 literal 0 HcmV?d00001 diff --git a/libvips/foreign/heifload.c b/libvips/foreign/heifload.c index 258de9a4..123778ad 100644 --- a/libvips/foreign/heifload.c +++ b/libvips/foreign/heifload.c @@ -493,7 +493,17 @@ vips_foreign_load_heif_set_header( VipsForeignLoadHeif *heif, VipsImage *out ) (VipsCallbackFn) NULL, data, length ); } else if( profile_type == heif_color_profile_type_nclx ) { - g_warning( "heifload: ignoring nclx profile" ); + /* nclx default coefficients are the same as bt709 + * FIXME .. apply any deltas to these defaults + */ + VipsBlob *blob; + size_t length; + const void *data; + + vips_profile_load( "bt709", &blob, NULL ); + data = vips_blob_get( blob, &length ); + vips_image_set_blob( out, VIPS_META_ICC_NAME, + (VipsCallbackFn) NULL, data, length ); } #endif /*HAVE_HEIF_COLOR_PROFILE*/