7#ifndef LCMSRGBP2020PQCOLORSPACETRANSFORMATION_H
8#define LCMSRGBP2020PQCOLORSPACETRANSFORMATION_H
29struct DstTraitsForSource {
39 typedef KoRgbF16Traits result;
44 typedef KoRgbF16Traits result;
48template <
typename src_channel_type,
49 typename dst_channel_type>
50struct RemoveSmpte2048Policy {
51 static ALWAYS_INLINE dst_channel_type process(src_channel_type
value,
float refWhite) {
61 if (!src || !
src->profile())
return 203.0;
62 return src->profile()->hdrReferenceWhite().value_or(203.0);
66template <
typename src_channel_type,
67 typename dst_channel_type>
68struct ApplySmpte2048Policy {
69 static ALWAYS_INLINE dst_channel_type process(src_channel_type
value,
float refWhite) {
80 return target->profile()->hdrReferenceWhite().value_or(203.0);
84template <
typename src_channel_type,
85 typename dst_channel_type>
87 static ALWAYS_INLINE dst_channel_type process(src_channel_type
value,
float refWhite) {
101template<
typename SrcCSTraits,
102 typename DstCSTraits,
103 template<
typename,
typename>
class Policy>
117 void transform(
const quint8 *src, quint8 *dst, qint32 nPixels)
const override {
120 const typename SrcCSTraits::Pixel *srcPixel =
reinterpret_cast<const typename SrcCSTraits::Pixel*
>(src);
121 typename DstCSTraits::Pixel *dstPixel =
reinterpret_cast<typename DstCSTraits::Pixel*
>(dst);
123 typedef typename SrcCSTraits::channels_type src_channel_type;
124 typedef typename DstCSTraits::channels_type dst_channel_type;
125 typedef Policy<src_channel_type, dst_channel_type> ConcretePolicy;
129 for (
int i = 0; i < nPixels; i++) {
130 dstPixel->red = ConcretePolicy::process(srcPixel->red, refWhite);
131 dstPixel->green = ConcretePolicy::process(srcPixel->green, refWhite);
132 dstPixel->blue = ConcretePolicy::process(srcPixel->blue, refWhite);
144template<class ParentColorSpace, class DstColorSpaceTraits = typename DstTraitsForSource<typename ParentColorSpace::ColorSpaceTraits>::result>
161 KoColorConversionTransformation::ConversionFlags conversionFlags)
const override
164 typename ParentColorSpace::ColorSpaceTraits,
166 RemoveSmpte2048Policy>(srcColorSpace,
173template<class ParentColorSpace, class DstColorSpaceTraits = typename DstTraitsForSource<typename ParentColorSpace::ColorSpaceTraits>::result>
190 KoColorConversionTransformation::ConversionFlags conversionFlags)
const override
194 typename ParentColorSpace::ColorSpaceTraits,
195 ApplySmpte2048Policy>(srcColorSpace,
202template<
class ParentColorSpace,
class DstColorSpaceTraits>
220 KoColorConversionTransformation::ConversionFlags conversionFlags)
const override
223 typename ParentColorSpace::ColorSpaceTraits,
225 NoopPolicy>(srcColorSpace,
float value(const T *src, size_t ch)
KisMagneticGraph::vertex_descriptor target(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
KoID colorDepthIdForChannelType()
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
ALWAYS_INLINE float applySmpte2048Curve(float x, float refWhite=203.0) noexcept
ALWAYS_INLINE float removeSmpte2048Curve(float x, float refWhite=203.0) noexcept
static _Tdst scaleToA(_T a)
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
void transform(const quint8 *src, quint8 *dst, qint32 nPixels) const override
ApplyRgbShaper(const KoColorSpace *srcCs, const KoColorSpace *dstCs, Intent renderingIntent, ConversionFlags conversionFlags)