1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 17:07:47 +00:00

LibGfx+icc: Read cicpType

This is a very new tag used for HDR content. The only files I know that
use it are the jpegs on https://ccameron-chromium.github.io/hdr-jpeg/
But they have an invalid ICC creation date, so `icc` can't process them.
(Commenting out the check for that does allow to print them.)

If the CIPC tag is present, it takes precedence about the actual data
in the profile and from what I understand, the ICC profile is
basically ignored. See https://www.color.org/events/HDR_experts.xalter
for background, in particular
https://www.color.org/hdr/02-Luke_Wallis.pdf (but the other talks
are very interesting too).

(PNG also has a cICP chunk that's supposed to take precedence over
iCCP.)
This commit is contained in:
Nico Weber 2023-02-07 21:35:14 -05:00 committed by Linus Groh
parent a434b89521
commit e8bbb3d915
5 changed files with 64 additions and 2 deletions

View file

@ -94,7 +94,7 @@ target_link_libraries(grep PRIVATE LibRegex)
target_link_libraries(gunzip PRIVATE LibCompress)
target_link_libraries(gzip PRIVATE LibCompress)
target_link_libraries(headless-browser PRIVATE LibCrypto LibGemini LibGfx LibHTTP LibTLS LibWeb LibWebSocket LibIPC LibJS)
target_link_libraries(icc PRIVATE LibGfx)
target_link_libraries(icc PRIVATE LibGfx LibVideo)
target_link_libraries(image2bin PRIVATE LibGfx)
target_link_libraries(jail-attach PRIVATE LibCore LibMain)
target_link_libraries(jail-create PRIVATE LibCore LibMain)

View file

@ -12,6 +12,7 @@
#include <LibGfx/ICC/Profile.h>
#include <LibGfx/ICC/Tags.h>
#include <LibGfx/ImageDecoder.h>
#include <LibVideo/Color/CodingIndependentCodePoints.h>
template<class T>
static ErrorOr<String> hyperlink(URL const& target, T const& label)
@ -125,7 +126,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
tag_data_to_first_signature.set(tag_data, tag_signature);
if (tag_data->type() == Gfx::ICC::CurveTagData::Type) {
if (tag_data->type() == Gfx::ICC::CicpTagData::Type) {
auto& cicp = static_cast<Gfx::ICC::CicpTagData&>(*tag_data);
outln(" color primaries: {} - {}", cicp.color_primaries(),
Video::color_primaries_to_string((Video::ColorPrimaries)cicp.color_primaries()));
outln(" transfer characteristics: {} - {}", cicp.transfer_characteristics(),
Video::transfer_characteristics_to_string((Video::TransferCharacteristics)cicp.transfer_characteristics()));
outln(" matrix coefficients: {} - {}", cicp.matrix_coefficients(),
Video::matrix_coefficients_to_string((Video::MatrixCoefficients)cicp.matrix_coefficients()));
outln(" video full range flag: {}", cicp.video_full_range_flag());
} else if (tag_data->type() == Gfx::ICC::CurveTagData::Type) {
auto& curve = static_cast<Gfx::ICC::CurveTagData&>(*tag_data);
if (curve.values().is_empty()) {
outln(" identity curve");