mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Adjustment merge + new brightness settings (#359)
* add new rgbtransform * activate rgbtransform * integrate new transform and gamma in adjustment, disable transform * fix brighness limit * advance upper and lower thresholds * start removing color transform * adjust configs/schema * implement json for new color adjustment * finish hyperion-remote extension for new adjustment settings * fix typos * rename luminance to brightness fix jsonapi for new adjustment * fix some bugs in adjustments * fix i18n * fix gamma via json * now brighness values goes from 0-1 with 0.5 is the default for all brighness is equal between the channels. less 0.5 all channels scaled down to new brighness, above 0.5 if possible channel gets brighter - but brighness is not equal between the channels anymore brighness value curve is now exponential instead of linear - this feels more natural * hslv cleanup
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
// Utils includes
|
||||
#include <utils/RgbChannelAdjustment.h>
|
||||
#include <utils/RgbTransform.h>
|
||||
|
||||
class ColorAdjustment
|
||||
{
|
||||
@@ -29,4 +30,6 @@ public:
|
||||
RgbChannelAdjustment _rgbMagentaAdjustment;
|
||||
/// The YELLOW (RGB-Channel) adjustment
|
||||
RgbChannelAdjustment _rgbYellowAdjustment;
|
||||
|
||||
RgbTransform _rgbTransform;
|
||||
};
|
||||
|
@@ -1,30 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// STL includes
|
||||
#include <string>
|
||||
|
||||
// Utils includes
|
||||
#include <utils/RgbChannelTransform.h>
|
||||
#include <utils/HsvTransform.h>
|
||||
#include <utils/HslTransform.h>
|
||||
|
||||
class ColorTransform
|
||||
{
|
||||
public:
|
||||
|
||||
/// Unique identifier for this color transform
|
||||
std::string _id;
|
||||
|
||||
/// The RED-Channel (RGB) transform
|
||||
RgbChannelTransform _rgbRedTransform;
|
||||
/// The GREEN-Channel (RGB) transform
|
||||
RgbChannelTransform _rgbGreenTransform;
|
||||
/// The BLUE-Channel (RGB) transform
|
||||
RgbChannelTransform _rgbBlueTransform;
|
||||
|
||||
/// The HSV Transform for applying Saturation and Value transforms
|
||||
HsvTransform _hsvTransform;
|
||||
|
||||
/// The HSL Transform for applying Saturation and Value transforms
|
||||
HslTransform _hslTransform;
|
||||
};
|
@@ -22,7 +22,6 @@
|
||||
// Hyperion includes
|
||||
#include <hyperion/LedString.h>
|
||||
#include <hyperion/PriorityMuxer.h>
|
||||
#include <hyperion/ColorTransform.h>
|
||||
#include <hyperion/ColorAdjustment.h>
|
||||
#include <hyperion/MessageForwarder.h>
|
||||
#include <hyperion/ComponentRegister.h>
|
||||
@@ -38,13 +37,9 @@
|
||||
// Forward class declaration
|
||||
class LedDevice;
|
||||
class LinearColorSmoothing;
|
||||
class ColorTransform;
|
||||
class RgbTransform;
|
||||
class EffectEngine;
|
||||
class HsvTransform;
|
||||
class HslTransform;
|
||||
class RgbChannelTransform;
|
||||
class RgbChannelAdjustment;
|
||||
class MultiColorTransform;
|
||||
class MultiColorAdjustment;
|
||||
class KODIVideoChecker;
|
||||
///
|
||||
@@ -67,14 +62,6 @@ public:
|
||||
BLACK, WHITE, RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW, INVALID
|
||||
};
|
||||
|
||||
///
|
||||
/// Enumeration of the possible color (color-channel) transforms
|
||||
///
|
||||
enum Transform
|
||||
{
|
||||
SATURATION_GAIN, VALUE_GAIN, THRESHOLD, GAMMA, BLACKLEVEL, WHITELEVEL
|
||||
};
|
||||
|
||||
///
|
||||
/// Destructor; cleans up resources
|
||||
///
|
||||
@@ -216,23 +203,11 @@ public slots:
|
||||
///
|
||||
void setImage(int priority, const Image<ColorRgb> & image, int duration_ms);
|
||||
|
||||
///
|
||||
/// Returns the list with unique transform identifiers
|
||||
/// @return The list with transform identifiers
|
||||
///
|
||||
const std::vector<std::string> & getTransformIds() const;
|
||||
|
||||
///
|
||||
/// Returns the list with unique adjustment identifiers
|
||||
/// @return The list with adjustment identifiers
|
||||
///
|
||||
const std::vector<std::string> & getAdjustmentIds() const;
|
||||
|
||||
///
|
||||
/// Returns the ColorTransform with the given identifier
|
||||
/// @return The transform with the given identifier (or nullptr if the identifier does not exist)
|
||||
///
|
||||
ColorTransform * getTransform(const std::string& id);
|
||||
|
||||
///
|
||||
/// Returns the ColorAdjustment with the given identifier
|
||||
@@ -246,9 +221,6 @@ public slots:
|
||||
///
|
||||
MessageForwarder * getForwarder();
|
||||
|
||||
/// Tell Hyperion that the transforms have changed and the leds need to be updated
|
||||
void transformsUpdated();
|
||||
|
||||
/// Tell Hyperion that the corrections have changed and the leds need to be updated
|
||||
void adjustmentsUpdated();
|
||||
|
||||
@@ -295,14 +267,9 @@ public:
|
||||
static LedString createLedString(const QJsonValue & ledsConfig, const ColorOrder deviceOrder);
|
||||
static LedString createLedStringClone(const QJsonValue & ledsConfig, const ColorOrder deviceOrder);
|
||||
|
||||
static MultiColorTransform * createLedColorsTransform(const unsigned ledCnt, const QJsonObject & colorTransformConfig);
|
||||
static MultiColorAdjustment * createLedColorsAdjustment(const unsigned ledCnt, const QJsonObject & colorAdjustmentConfig);
|
||||
static ColorTransform * createColorTransform(const QJsonObject & transformConfig);
|
||||
static ColorAdjustment * createColorAdjustment(const QJsonObject & adjustmentConfig);
|
||||
static HsvTransform * createHsvTransform(const QJsonObject & hsvConfig);
|
||||
static HslTransform * createHslTransform(const QJsonObject & hslConfig);
|
||||
static RgbChannelTransform * createRgbChannelTransform(const QJsonObject& colorConfig);
|
||||
static RgbChannelAdjustment * createRgbChannelCorrection(const QJsonObject& colorConfig);
|
||||
static RgbTransform * createRgbTransform(const QJsonObject& colorConfig);
|
||||
static RgbChannelAdjustment * createRgbChannelAdjustment(const QJsonArray& colorConfig, const RgbChannel color);
|
||||
|
||||
static LinearColorSmoothing * createColorSmoothing(const QJsonObject & smoothingConfig, LedDevice* leddevice);
|
||||
@@ -349,9 +316,6 @@ private:
|
||||
/// The priority muxer
|
||||
PriorityMuxer _muxer;
|
||||
|
||||
/// The transformation from raw colors to led colors
|
||||
MultiColorTransform * _raw2ledTransform;
|
||||
|
||||
/// The adjustment from raw colors to led colors
|
||||
MultiColorAdjustment * _raw2ledAdjustment;
|
||||
|
||||
@@ -393,12 +357,6 @@ private:
|
||||
/// flag for v4l color correction
|
||||
bool _colorAdjustmentV4Lonly;
|
||||
|
||||
/// flag for v4l color correction
|
||||
bool _colorTransformV4Lonly;
|
||||
|
||||
/// flag for color transform enable
|
||||
bool _transformEnabled;
|
||||
|
||||
/// flag for color adjustment enable
|
||||
bool _adjustmentEnabled;
|
||||
|
||||
|
@@ -4,68 +4,36 @@
|
||||
#include <cstdint>
|
||||
|
||||
///
|
||||
/// Color transformation to adjust the saturation and value of a RGB color value
|
||||
/// Color transformation to adjust the saturation and luminance of a RGB color value
|
||||
///
|
||||
class HsvTransform
|
||||
class ColorSys
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Default constructor
|
||||
/// Translates an RGB (red, green, blue) color to an HSL (hue, saturation, luminance) color
|
||||
///
|
||||
HsvTransform();
|
||||
/// @param[in] red The red RGB-component
|
||||
/// @param[in] green The green RGB-component
|
||||
/// @param[in] blue The blue RGB-component
|
||||
/// @param[out] hue The hue HSL-component
|
||||
/// @param[out] saturation The saturation HSL-component
|
||||
/// @param[out] luminance The luminance HSL-component
|
||||
///
|
||||
|
||||
static void rgb2hsl(uint8_t red, uint8_t green, uint8_t blue, uint16_t & hue, float & saturation, float & luminance);
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
/// Translates an HSL (hue, saturation, luminance) color to an RGB (red, green, blue) color
|
||||
///
|
||||
/// @param saturationGain The used saturation gain
|
||||
/// @param valueGain The used value gain
|
||||
/// @param[in] hue The hue HSL-component
|
||||
/// @param[in] saturation The saturation HSL-component
|
||||
/// @param[in] luminance The luminance HSL-component
|
||||
/// @param[out] red The red RGB-component
|
||||
/// @param[out] green The green RGB-component
|
||||
/// @param[out] blue The blue RGB-component
|
||||
///
|
||||
HsvTransform(double saturationGain, double valueGain);
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
~HsvTransform();
|
||||
|
||||
///
|
||||
/// Updates the saturation gain
|
||||
///
|
||||
/// @param saturationGain New saturationGain
|
||||
///
|
||||
void setSaturationGain(double saturationGain);
|
||||
|
||||
///
|
||||
/// Returns the saturation gain
|
||||
///
|
||||
/// @return The current Saturation gain
|
||||
///
|
||||
double getSaturationGain() const;
|
||||
|
||||
///
|
||||
/// Updates the value gain
|
||||
///
|
||||
/// @param valueGain New value gain
|
||||
///
|
||||
void setValueGain(double valueGain);
|
||||
|
||||
///
|
||||
/// Returns the value gain
|
||||
///
|
||||
/// @return The current value gain
|
||||
///
|
||||
double getValueGain() const;
|
||||
|
||||
///
|
||||
/// Apply the transform the the given RGB values.
|
||||
///
|
||||
/// @param red The red color component
|
||||
/// @param green The green color component
|
||||
/// @param blue The blue color component
|
||||
///
|
||||
/// @note The values are updated in place.
|
||||
///
|
||||
void transform(uint8_t & red, uint8_t & green, uint8_t & blue) const;
|
||||
|
||||
static void hsl2rgb(uint16_t hue, float saturation, float luminance, uint8_t & red, uint8_t & green, uint8_t & blue);
|
||||
///
|
||||
/// Translates an RGB (red, green, blue) color to an HSV (hue, saturation, value) color
|
||||
///
|
||||
@@ -97,10 +65,4 @@ public:
|
||||
/// number and scaled between 0 and 360
|
||||
///
|
||||
static void hsv2rgb(uint16_t hue, uint8_t saturation, uint8_t value, uint8_t & red, uint8_t & green, uint8_t & blue);
|
||||
|
||||
private:
|
||||
/// The saturation gain
|
||||
double _saturationGain;
|
||||
/// The value gain
|
||||
double _valueGain;
|
||||
};
|
@@ -1,116 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// STL includes
|
||||
#include <cstdint>
|
||||
|
||||
///
|
||||
/// Color transformation to adjust the saturation and luminance of a RGB color value
|
||||
///
|
||||
class HslTransform
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Default constructor
|
||||
///
|
||||
HslTransform();
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
/// @param saturationGain The used saturation gain
|
||||
/// @param luminanceGain The used luminance gain
|
||||
///
|
||||
HslTransform(double saturationGain, double luminanceGain, double luminanceMinimum);
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
~HslTransform();
|
||||
|
||||
///
|
||||
/// Updates the saturation gain
|
||||
///
|
||||
/// @param saturationGain New saturationGain
|
||||
///
|
||||
void setSaturationGain(double saturationGain);
|
||||
|
||||
///
|
||||
/// Returns the saturation gain
|
||||
///
|
||||
/// @return The current Saturation gain
|
||||
///
|
||||
double getSaturationGain() const;
|
||||
|
||||
///
|
||||
/// Updates the luminance gain
|
||||
///
|
||||
/// @param luminanceGain New luminance gain
|
||||
///
|
||||
void setLuminanceGain(double luminanceGain);
|
||||
|
||||
///
|
||||
/// Returns the luminance gain
|
||||
///
|
||||
/// @return The current luminance gain
|
||||
///
|
||||
double getLuminanceGain() const;
|
||||
|
||||
///
|
||||
/// Updates the luminance minimum
|
||||
///
|
||||
/// @param luminanceMinimum New luminance minimum
|
||||
///
|
||||
void setLuminanceMinimum(double luminanceMinimum);
|
||||
|
||||
///
|
||||
/// Returns the luminance minimum
|
||||
///
|
||||
/// @return The current luminance minimum
|
||||
///
|
||||
double getLuminanceMinimum() const;
|
||||
|
||||
///
|
||||
/// Apply the transform the the given RGB values.
|
||||
///
|
||||
/// @param red The red color component
|
||||
/// @param green The green color component
|
||||
/// @param blue The blue color component
|
||||
///
|
||||
/// @note The values are updated in place.
|
||||
///
|
||||
void transform(uint8_t & red, uint8_t & green, uint8_t & blue) const;
|
||||
|
||||
///
|
||||
/// Translates an RGB (red, green, blue) color to an HSL (hue, saturation, luminance) color
|
||||
///
|
||||
/// @param[in] red The red RGB-component
|
||||
/// @param[in] green The green RGB-component
|
||||
/// @param[in] blue The blue RGB-component
|
||||
/// @param[out] hue The hue HSL-component
|
||||
/// @param[out] saturation The saturation HSL-component
|
||||
/// @param[out] luminance The luminance HSL-component
|
||||
///
|
||||
|
||||
static void rgb2hsl(uint8_t red, uint8_t green, uint8_t blue, uint16_t & hue, float & saturation, float & luminance);
|
||||
|
||||
///
|
||||
/// Translates an HSL (hue, saturation, luminance) color to an RGB (red, green, blue) color
|
||||
///
|
||||
/// @param[in] hue The hue HSL-component
|
||||
/// @param[in] saturation The saturation HSL-component
|
||||
/// @param[in] luminance The luminance HSL-component
|
||||
/// @param[out] red The red RGB-component
|
||||
/// @param[out] green The green RGB-component
|
||||
/// @param[out] blue The blue RGB-component
|
||||
///
|
||||
|
||||
static void hsl2rgb(uint16_t hue, float saturation, float luminance, uint8_t & red, uint8_t & green, uint8_t & blue);
|
||||
|
||||
private:
|
||||
/// The saturation gain
|
||||
double _saturationGain;
|
||||
/// The luminance gain
|
||||
double _luminanceGain;
|
||||
/// The luminance minimum
|
||||
double _luminanceMinimum;
|
||||
};
|
@@ -1,86 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// STL includes
|
||||
#include <cstdint>
|
||||
|
||||
/// Transform for a single color byte value
|
||||
///
|
||||
/// Transforms are applied in the following order:
|
||||
/// 1) a threshold is applied. All values below threshold will be set to zero
|
||||
/// 2) gamma color correction is applied
|
||||
/// 3) the output value is scaled from the [0:1] to [blacklevel:whitelevel]
|
||||
/// 4) finally, in case of a weird choice of parameters, the output is clamped between [0:1]
|
||||
///
|
||||
/// All configuration values are doubles and assume the color value to be between 0 and 1
|
||||
class RgbChannelTransform
|
||||
{
|
||||
public:
|
||||
/// Default constructor
|
||||
RgbChannelTransform();
|
||||
|
||||
/// Constructor
|
||||
/// @param threshold The minimum threshold
|
||||
/// @param gamma The gamma of the gamma-curve correction
|
||||
/// @param blacklevel The minimum value for the RGB-Channel
|
||||
/// @param whitelevel The maximum value for the RGB-Channel
|
||||
RgbChannelTransform(double threshold, double gamma, double blacklevel, double whitelevel);
|
||||
|
||||
/// Destructor
|
||||
~RgbChannelTransform();
|
||||
|
||||
/// setAdjustment RGB
|
||||
/// @param threshold The minimum threshold
|
||||
/// @param gamma The gamma of the gamma-curve correction
|
||||
/// @param blacklevel The minimum value for the RGB-Channel
|
||||
/// @param whitelevel The maximum value for the RGB-Channel
|
||||
void setTransform(double threshold, double gamma, double blacklevel, double whitelevel);
|
||||
|
||||
/// @return The current threshold value
|
||||
double getThreshold() const;
|
||||
|
||||
/// @param threshold New threshold value
|
||||
void setThreshold(double threshold);
|
||||
|
||||
/// @return The current gamma value
|
||||
double getGamma() const;
|
||||
|
||||
/// @param gamma New gamma value
|
||||
void setGamma(double gamma);
|
||||
|
||||
/// @return The current blacklevel value
|
||||
double getBlacklevel() const;
|
||||
|
||||
/// @param blacklevel New blacklevel value
|
||||
void setBlacklevel(double blacklevel);
|
||||
|
||||
/// @return The current whitelevel value
|
||||
double getWhitelevel() const;
|
||||
|
||||
/// @param whitelevel New whitelevel value
|
||||
void setWhitelevel(double whitelevel);
|
||||
|
||||
/// Transform the given byte value
|
||||
/// @param input The input color byte
|
||||
/// @return The transformed byte value
|
||||
uint8_t transform(uint8_t input) const
|
||||
{
|
||||
return _mapping[input];
|
||||
}
|
||||
|
||||
private:
|
||||
/// (re)-initilize the color mapping
|
||||
void initializeMapping();
|
||||
|
||||
private:
|
||||
/// The threshold value
|
||||
double _threshold;
|
||||
/// The gamma value
|
||||
double _gamma;
|
||||
/// The blacklevel
|
||||
double _blacklevel;
|
||||
/// The whitelevel
|
||||
double _whitelevel;
|
||||
|
||||
/// The mapping from input color to output color
|
||||
uint8_t _mapping[256];
|
||||
};
|
96
include/utils/RgbTransform.h
Normal file
96
include/utils/RgbTransform.h
Normal file
@@ -0,0 +1,96 @@
|
||||
#pragma once
|
||||
|
||||
// STL includes
|
||||
#include <cstdint>
|
||||
|
||||
///
|
||||
/// Color transformation to adjust the saturation and value of a RGB color value
|
||||
///
|
||||
class RgbTransform
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Default constructor
|
||||
///
|
||||
RgbTransform();
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
/// @param gammaR The used red gamma
|
||||
/// @param gammaG The used green gamma
|
||||
/// @param gammab The used blue gamma
|
||||
/// @param brightnessLow The used lower brightness
|
||||
/// @param brightnessHigh The used higher brightness
|
||||
///
|
||||
RgbTransform(double gammaR, double gammaG, double gammaB, double brightnessLow, double brightnessHigh);
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
~RgbTransform();
|
||||
|
||||
/// @return The current red gamma value
|
||||
double getGammaR() const;
|
||||
|
||||
/// @return The current green gamma value
|
||||
double getGammaG() const;
|
||||
|
||||
/// @return The current blue gamma value
|
||||
double getGammaB() const;
|
||||
|
||||
/// @param gamma New gamma value
|
||||
void setGamma(double gammaR,double gammaG=-1, double gammaB=-1);
|
||||
|
||||
/// @return The current lower brightness
|
||||
double getBrightnessMin() const;
|
||||
|
||||
/// @param gamma New lower brightness
|
||||
void setBrightnessMin(double brightness);
|
||||
|
||||
/// @return The current lower brightness
|
||||
double getBrightness() const;
|
||||
|
||||
/// @param gamma New lower brightness
|
||||
void setBrightness(double brightness);
|
||||
|
||||
///
|
||||
/// Apply the transform the the given RGB values.
|
||||
///
|
||||
/// @param red The red color component
|
||||
/// @param green The green color component
|
||||
/// @param blue The blue color component
|
||||
///
|
||||
/// @note The values are updated in place.
|
||||
///
|
||||
void transform(uint8_t & red, uint8_t & green, uint8_t & blue);
|
||||
|
||||
private:
|
||||
///
|
||||
/// init
|
||||
///
|
||||
/// @param gammaR The used red gamma
|
||||
/// @param gammaG The used green gamma
|
||||
/// @param gammab The used blue gamma
|
||||
/// @param brightnessLow The used lower brightness
|
||||
/// @param brightnessHigh The used higher brightness
|
||||
///
|
||||
void init(double gammaR, double gammaG, double gammaB, double brightnessLow, double brightnessHigh);
|
||||
|
||||
/// (re)-initilize the color mapping
|
||||
void initializeMapping(); /// The saturation gain
|
||||
|
||||
double _brightnessLow;
|
||||
double _brightnessHigh;
|
||||
double _sumBrightnessLow;
|
||||
double _sumBrightnessHigh;
|
||||
|
||||
double _gammaR;
|
||||
double _gammaG;
|
||||
double _gammaB;
|
||||
|
||||
/// The mapping from input color to output color
|
||||
uint8_t _mappingR[256];
|
||||
uint8_t _mappingG[256];
|
||||
uint8_t _mappingB[256];
|
||||
};
|
Reference in New Issue
Block a user