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

LibGfx/ICC: Plumb mBA conversion from profile to tag data

It's still implemented on the tag data side, so no real
behavior change.
This commit is contained in:
Nico Weber 2023-12-06 19:58:34 -05:00 committed by Andreas Kling
parent 07fe8b8d0a
commit d17e8d1654
2 changed files with 23 additions and 4 deletions

View file

@ -1416,7 +1416,7 @@ static TagSignature backward_transform_tag_for_rendering_intent(RenderingIntent
VERIFY_NOT_REACHED();
}
ErrorOr<void> Profile::from_pcs_b_to_a(TagData const& tag_data, FloatVector3 const&, Bytes) const
ErrorOr<void> Profile::from_pcs_b_to_a(TagData const& tag_data, FloatVector3 const& pcs, Bytes out_bytes) const
{
switch (tag_data.type()) {
case Lut16TagData::Type:
@ -1425,9 +1425,16 @@ ErrorOr<void> Profile::from_pcs_b_to_a(TagData const& tag_data, FloatVector3 con
case Lut8TagData::Type:
// FIXME
return Error::from_string_literal("ICC::Profile::to_pcs: BToA*Tag handling for mft1 tags not yet implemented");
case LutBToATagData::Type:
// FIXME
return Error::from_string_literal("ICC::Profile::to_pcs: BToA*Tag handling for mBA tags not yet implemented");
case LutBToATagData::Type: {
auto const& b_to_a = static_cast<LutBToATagData const&>(tag_data);
if (b_to_a.number_of_input_channels() != number_of_components_in_color_space(connection_space()))
return Error::from_string_literal("ICC::Profile::from_pcs_b_to_a: mBA input channel count does not match color space size");
if (b_to_a.number_of_output_channels() != number_of_components_in_color_space(data_color_space()))
return Error::from_string_literal("ICC::Profile::from_pcs_b_to_a: mBA output channel count does not match profile connection space size");
return b_to_a.evaluate(connection_space(), pcs, out_bytes);
}
}
VERIFY_NOT_REACHED();
}

View file

@ -519,6 +519,9 @@ public:
Optional<CLUTData> const& clut() const { return m_clut; }
Optional<Vector<LutCurveType>> const& a_curves() const { return m_a_curves; }
// Returns the result of the LUT pipeline for u8 outputs.
ErrorOr<void> evaluate(ColorSpace connection_space, FloatVector3 const&, Bytes) const;
private:
u8 m_number_of_input_channels;
u8 m_number_of_output_channels;
@ -1300,6 +1303,15 @@ inline ErrorOr<FloatVector3> LutAToBTagData::evaluate(ColorSpace connection_spac
return output_color;
}
inline ErrorOr<void> LutBToATagData::evaluate(ColorSpace connection_space, FloatVector3 const&, Bytes out_bytes) const
{
VERIFY(connection_space == ColorSpace::PCSXYZ || connection_space == ColorSpace::PCSLAB);
VERIFY(number_of_input_channels() == 3);
VERIFY(number_of_output_channels() == out_bytes.size());
return Error::from_string_literal("LutBToATagData::evaluate: Not yet implemented");
}
}
template<>