core/colorspace: make max brightness values optional
Zero is already optional, but it's easy to make mistakes that way
This commit is contained in:
parent
bdc24ff8c7
commit
eb7b04e320
7 changed files with 27 additions and 24 deletions
|
@ -202,7 +202,7 @@ bool EglGbmLayerSurface::endRendering(const QRegion &damagedRegion, OutputFrame
|
|||
binder.shader()->setUniform(GLShader::IntUniform::SourceNamedTransferFunction, int(m_surface->intermediaryColorDescription.transferFunction()));
|
||||
binder.shader()->setUniform(GLShader::IntUniform::DestinationNamedTransferFunction, int(m_surface->targetColorDescription.transferFunction()));
|
||||
binder.shader()->setUniform(GLShader::FloatUniform::SdrBrightness, m_surface->intermediaryColorDescription.sdrBrightness());
|
||||
binder.shader()->setUniform(GLShader::FloatUniform::MaxHdrBrightness, m_surface->intermediaryColorDescription.maxHdrHighlightBrightness());
|
||||
binder.shader()->setUniform(GLShader::FloatUniform::MaxHdrBrightness, m_surface->intermediaryColorDescription.maxHdrHighlightBrightness().value_or(800));
|
||||
}
|
||||
QMatrix4x4 mat;
|
||||
mat.scale(1, -1);
|
||||
|
|
|
@ -382,7 +382,7 @@ ColorDescription DrmOutput::createColorDescription(const std::shared_ptr<OutputC
|
|||
const NamedTransferFunction transferFunction = effectiveHdr ? NamedTransferFunction::PerceptualQuantizer : NamedTransferFunction::gamma22;
|
||||
const double minBrightness = effectiveHdr ? props->minBrightnessOverride.value_or(m_state.minBrightnessOverride).value_or(m_connector->edid()->desiredMinLuminance()) : 0;
|
||||
const double maxAverageBrightness = effectiveHdr ? props->maxAverageBrightnessOverride.value_or(m_state.maxAverageBrightnessOverride).value_or(m_connector->edid()->desiredMaxFrameAverageLuminance().value_or(m_state.sdrBrightness)) : 200;
|
||||
const double maxPeakBrightness = effectiveHdr ? props->maxPeakBrightnessOverride.value_or(m_state.maxPeakBrightnessOverride).value_or(m_connector->edid()->desiredMaxLuminance().value_or(1000)) : 200;
|
||||
const double maxPeakBrightness = effectiveHdr ? props->maxPeakBrightnessOverride.value_or(m_state.maxPeakBrightnessOverride).value_or(m_connector->edid()->desiredMaxLuminance().value_or(800)) : 200;
|
||||
const double sdrBrightness = effectiveHdr ? props->sdrBrightness.value_or(m_state.sdrBrightness) : maxPeakBrightness;
|
||||
return ColorDescription(containerColorimetry, transferFunction, sdrBrightness, minBrightness, maxAverageBrightness, maxPeakBrightness, masteringColorimetry, sdrColorimetry);
|
||||
}
|
||||
|
|
|
@ -200,17 +200,17 @@ const Colorimetry &Colorimetry::fromName(NamedColorimetry name)
|
|||
|
||||
const ColorDescription ColorDescription::sRGB = ColorDescription(NamedColorimetry::BT709, NamedTransferFunction::gamma22, 100, 0, 100, 100);
|
||||
|
||||
ColorDescription::ColorDescription(const Colorimetry &containerColorimetry, NamedTransferFunction tf, double sdrBrightness, double minHdrBrightness, double maxFrameAverageBrightness, double maxHdrHighlightBrightness)
|
||||
ColorDescription::ColorDescription(const Colorimetry &containerColorimetry, NamedTransferFunction tf, double sdrBrightness, double minHdrBrightness, std::optional<double> maxFrameAverageBrightness, std::optional<double> maxHdrHighlightBrightness)
|
||||
: ColorDescription(containerColorimetry, tf, sdrBrightness, minHdrBrightness, maxFrameAverageBrightness, maxHdrHighlightBrightness, std::nullopt, Colorimetry::fromName(NamedColorimetry::BT709))
|
||||
{
|
||||
}
|
||||
|
||||
ColorDescription::ColorDescription(NamedColorimetry containerColorimetry, NamedTransferFunction tf, double sdrBrightness, double minHdrBrightness, double maxFrameAverageBrightness, double maxHdrHighlightBrightness)
|
||||
ColorDescription::ColorDescription(NamedColorimetry containerColorimetry, NamedTransferFunction tf, double sdrBrightness, double minHdrBrightness, std::optional<double> maxFrameAverageBrightness, std::optional<double> maxHdrHighlightBrightness)
|
||||
: ColorDescription(Colorimetry::fromName(containerColorimetry), tf, sdrBrightness, minHdrBrightness, maxFrameAverageBrightness, maxHdrHighlightBrightness, std::nullopt, Colorimetry::fromName(NamedColorimetry::BT709))
|
||||
{
|
||||
}
|
||||
|
||||
ColorDescription::ColorDescription(const Colorimetry &containerColorimetry, NamedTransferFunction tf, double sdrBrightness, double minHdrBrightness, double maxFrameAverageBrightness, double maxHdrHighlightBrightness, std::optional<Colorimetry> masteringColorimetry, const Colorimetry &sdrColorimetry)
|
||||
ColorDescription::ColorDescription(const Colorimetry &containerColorimetry, NamedTransferFunction tf, double sdrBrightness, double minHdrBrightness, std::optional<double> maxFrameAverageBrightness, std::optional<double> maxHdrHighlightBrightness, std::optional<Colorimetry> masteringColorimetry, const Colorimetry &sdrColorimetry)
|
||||
: m_containerColorimetry(containerColorimetry)
|
||||
, m_masteringColorimetry(masteringColorimetry)
|
||||
, m_transferFunction(tf)
|
||||
|
@ -222,7 +222,7 @@ ColorDescription::ColorDescription(const Colorimetry &containerColorimetry, Name
|
|||
{
|
||||
}
|
||||
|
||||
ColorDescription::ColorDescription(NamedColorimetry containerColorimetry, NamedTransferFunction tf, double sdrBrightness, double minHdrBrightness, double maxFrameAverageBrightness, double maxHdrHighlightBrightness, std::optional<Colorimetry> masteringColorimetry, const Colorimetry &sdrColorimetry)
|
||||
ColorDescription::ColorDescription(NamedColorimetry containerColorimetry, NamedTransferFunction tf, double sdrBrightness, double minHdrBrightness, std::optional<double> maxFrameAverageBrightness, std::optional<double> maxHdrHighlightBrightness, std::optional<Colorimetry> masteringColorimetry, const Colorimetry &sdrColorimetry)
|
||||
: ColorDescription(Colorimetry::fromName(containerColorimetry), tf, sdrBrightness, minHdrBrightness, maxFrameAverageBrightness, maxHdrHighlightBrightness, masteringColorimetry, sdrColorimetry)
|
||||
{
|
||||
}
|
||||
|
@ -257,12 +257,12 @@ double ColorDescription::minHdrBrightness() const
|
|||
return m_minHdrBrightness;
|
||||
}
|
||||
|
||||
double ColorDescription::maxFrameAverageBrightness() const
|
||||
std::optional<double> ColorDescription::maxFrameAverageBrightness() const
|
||||
{
|
||||
return m_maxFrameAverageBrightness;
|
||||
}
|
||||
|
||||
double ColorDescription::maxHdrHighlightBrightness() const
|
||||
std::optional<double> ColorDescription::maxHdrHighlightBrightness() const
|
||||
{
|
||||
return m_maxHdrHighlightBrightness;
|
||||
}
|
||||
|
|
|
@ -111,10 +111,10 @@ public:
|
|||
* @param maxHdrHighlightBrightness the maximum brightness of HDR content, for a small part of the screen only
|
||||
* @param sdrColorimetry
|
||||
*/
|
||||
explicit ColorDescription(const Colorimetry &containerColorimetry, NamedTransferFunction tf, double sdrBrightness, double minHdrBrightness, double maxFrameAverageBrightness, double maxHdrHighlightBrightness);
|
||||
explicit ColorDescription(NamedColorimetry containerColorimetry, NamedTransferFunction tf, double sdrBrightness, double minHdrBrightness, double maxFrameAverageBrightness, double maxHdrHighlightBrightness);
|
||||
explicit ColorDescription(const Colorimetry &containerColorimetry, NamedTransferFunction tf, double sdrBrightness, double minHdrBrightness, double maxFrameAverageBrightness, double maxHdrHighlightBrightness, std::optional<Colorimetry> masteringColorimetry, const Colorimetry &sdrColorimetry);
|
||||
explicit ColorDescription(NamedColorimetry containerColorimetry, NamedTransferFunction tf, double sdrBrightness, double minHdrBrightness, double maxFrameAverageBrightness, double maxHdrHighlightBrightness, std::optional<Colorimetry> masteringColorimetry, const Colorimetry &sdrColorimetry);
|
||||
explicit ColorDescription(const Colorimetry &containerColorimetry, NamedTransferFunction tf, double sdrBrightness, double minHdrBrightness, std::optional<double> maxFrameAverageBrightness, std::optional<double> maxHdrHighlightBrightness);
|
||||
explicit ColorDescription(NamedColorimetry containerColorimetry, NamedTransferFunction tf, double sdrBrightness, double minHdrBrightness, std::optional<double> maxFrameAverageBrightness, std::optional<double> maxHdrHighlightBrightness);
|
||||
explicit ColorDescription(const Colorimetry &containerColorimetry, NamedTransferFunction tf, double sdrBrightness, double minHdrBrightness, std::optional<double> maxFrameAverageBrightness, std::optional<double> maxHdrHighlightBrightness, std::optional<Colorimetry> masteringColorimetry, const Colorimetry &sdrColorimetry);
|
||||
explicit ColorDescription(NamedColorimetry containerColorimetry, NamedTransferFunction tf, double sdrBrightness, double minHdrBrightness, std::optional<double> maxFrameAverageBrightness, std::optional<double> maxHdrHighlightBrightness, std::optional<Colorimetry> masteringColorimetry, const Colorimetry &sdrColorimetry);
|
||||
|
||||
/**
|
||||
* The primaries and whitepoint that colors are encoded for. This is used to convert between different colorspaces.
|
||||
|
@ -131,8 +131,8 @@ public:
|
|||
NamedTransferFunction transferFunction() const;
|
||||
double sdrBrightness() const;
|
||||
double minHdrBrightness() const;
|
||||
double maxFrameAverageBrightness() const;
|
||||
double maxHdrHighlightBrightness() const;
|
||||
std::optional<double> maxFrameAverageBrightness() const;
|
||||
std::optional<double> maxHdrHighlightBrightness() const;
|
||||
|
||||
bool operator==(const ColorDescription &other) const = default;
|
||||
|
||||
|
@ -152,7 +152,7 @@ private:
|
|||
Colorimetry m_sdrColorimetry;
|
||||
double m_sdrBrightness;
|
||||
double m_minHdrBrightness;
|
||||
double m_maxFrameAverageBrightness;
|
||||
double m_maxHdrHighlightBrightness;
|
||||
std::optional<double> m_maxFrameAverageBrightness;
|
||||
std::optional<double> m_maxHdrHighlightBrightness;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -453,7 +453,7 @@ bool GLShader::setColorspaceUniforms(const ColorDescription &src, const ColorDes
|
|||
&& setUniform(GLShader::IntUniform::SourceNamedTransferFunction, int(src.transferFunction()))
|
||||
&& setUniform(GLShader::IntUniform::DestinationNamedTransferFunction, int(dst.transferFunction()))
|
||||
&& setUniform(FloatUniform::SdrBrightness, dst.sdrBrightness())
|
||||
&& setUniform(FloatUniform::MaxHdrBrightness, dst.maxHdrHighlightBrightness());
|
||||
&& setUniform(FloatUniform::MaxHdrBrightness, dst.maxHdrHighlightBrightness().value_or(10'000));
|
||||
}
|
||||
|
||||
bool GLShader::setColorspaceUniformsFromSRGB(const ColorDescription &dst)
|
||||
|
|
|
@ -80,9 +80,9 @@ void FrogColorManagementSurfaceV1::setPreferredColorDescription(const ColorDescr
|
|||
encodePrimary(color.green().x()), encodePrimary(color.green().y()),
|
||||
encodePrimary(color.blue().x()), encodePrimary(color.blue().y()),
|
||||
encodePrimary(color.white().x()), encodePrimary(color.white().y()),
|
||||
std::round(colorDescription.maxHdrHighlightBrightness()),
|
||||
std::round(colorDescription.maxHdrHighlightBrightness().value_or(0)),
|
||||
std::round(colorDescription.minHdrBrightness() / 0.0001),
|
||||
std::round(colorDescription.maxFrameAverageBrightness()));
|
||||
std::round(colorDescription.maxFrameAverageBrightness().value_or(0)));
|
||||
}
|
||||
|
||||
void FrogColorManagementSurfaceV1::frog_color_managed_surface_set_known_transfer_function(Resource *resource, uint32_t transfer_function)
|
||||
|
@ -130,8 +130,12 @@ void FrogColorManagementSurfaceV1::frog_color_managed_surface_set_hdr_metadata(R
|
|||
uint32_t max_display_mastering_luminance, uint32_t min_display_mastering_luminance,
|
||||
uint32_t max_cll, uint32_t max_fall)
|
||||
{
|
||||
m_maxPeakBrightness = max_cll;
|
||||
m_maxFrameAverageBrightness = max_fall;
|
||||
if (max_fall > 0) {
|
||||
m_maxFrameAverageBrightness = max_fall;
|
||||
}
|
||||
if (max_cll > 0) {
|
||||
m_maxPeakBrightness = max_cll;
|
||||
}
|
||||
if (mastering_display_primary_red_x > 0 && mastering_display_primary_red_y > 0 && mastering_display_primary_green_x > 0 && mastering_display_primary_green_y > 0 && mastering_display_primary_blue_x > 0 && mastering_display_primary_blue_y > 0 && mastering_white_point_x > 0 && mastering_white_point_y > 0) {
|
||||
m_masteringColorimetry = Colorimetry{
|
||||
QVector2D(mastering_display_primary_red_x / 10'000.0, mastering_display_primary_red_y / 10'000.0),
|
||||
|
@ -156,7 +160,6 @@ void FrogColorManagementSurfaceV1::frog_color_managed_surface_destroy_resource(R
|
|||
void FrogColorManagementSurfaceV1::updateColorDescription()
|
||||
{
|
||||
if (m_surface) {
|
||||
// TODO make brightness values optional in ColorDescription
|
||||
SurfaceInterfacePrivate *priv = SurfaceInterfacePrivate::get(m_surface);
|
||||
priv->pending->colorDescription = ColorDescription(m_containerColorimetry, m_transferFunction, 0, 0, m_maxFrameAverageBrightness, m_maxPeakBrightness, m_masteringColorimetry, Colorimetry::fromName(NamedColorimetry::BT709));
|
||||
priv->pending->colorDescriptionIsSet = true;
|
||||
|
|
|
@ -56,8 +56,8 @@ private:
|
|||
NamedTransferFunction m_transferFunction = NamedTransferFunction::sRGB;
|
||||
NamedColorimetry m_containerColorimetry = NamedColorimetry::BT709;
|
||||
std::optional<Colorimetry> m_masteringColorimetry;
|
||||
float m_maxFrameAverageBrightness = 0;
|
||||
float m_maxPeakBrightness = 0;
|
||||
std::optional<double> m_maxFrameAverageBrightness;
|
||||
std::optional<double> m_maxPeakBrightness;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue