mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Filter rework, next step (#82)
* common ledbuffer for color transform hyperion class uses a common buffer for all operations on ledColors got from muxer all color transforms uses new ledBuffer instead of making copies of ledbuffer other fixes: fix compile bug in profiler update doxygen config * migrate logging for color transform classes * prepare new logger in hyperion class * implement hwledcount * Update Hyperion.cpp Fix off color * remove ledscount equivalent from apa102 migrate logging in hyperion.cpp remove unused and duuplicate colorcorrection - but same is available through tempertature * remove colorcorrection completly fix compile * set colororder back to static * in remote: using correction is the same as using temperature - correction is obsolete, command not delete atm for compat reasons * refactoring of RgbChannelAdjustment * - remove rgbchannelcorrection, this was a dup of rgbchanneladjustment - add cmake policy to hide warning - tune code of rgbchanneltransform
This commit is contained in:
@@ -116,7 +116,7 @@ ColorCorrection * Hyperion::createColorCorrection(const Json::Value & correction
|
||||
{
|
||||
const std::string id = correctionConfig.get("id", "default").asString();
|
||||
|
||||
RgbChannelCorrection * rgbCorrection = createRgbChannelCorrection(correctionConfig["correctionValues"]);
|
||||
RgbChannelAdjustment * rgbCorrection = createRgbChannelCorrection(correctionConfig["correctionValues"]);
|
||||
|
||||
ColorCorrection * correction = new ColorCorrection();
|
||||
correction->_id = id;
|
||||
@@ -404,13 +404,13 @@ RgbChannelTransform* Hyperion::createRgbChannelTransform(const Json::Value& colo
|
||||
return transform;
|
||||
}
|
||||
|
||||
RgbChannelCorrection* Hyperion::createRgbChannelCorrection(const Json::Value& colorConfig)
|
||||
RgbChannelAdjustment* Hyperion::createRgbChannelCorrection(const Json::Value& colorConfig)
|
||||
{
|
||||
const int varR = colorConfig.get("red", 255).asInt();
|
||||
const int varG = colorConfig.get("green", 255).asInt();
|
||||
const int varB = colorConfig.get("blue", 255).asInt();
|
||||
|
||||
RgbChannelCorrection* correction = new RgbChannelCorrection(varR, varG, varB);
|
||||
RgbChannelAdjustment* correction = new RgbChannelAdjustment(varR, varG, varB);
|
||||
return correction;
|
||||
}
|
||||
|
||||
|
@@ -85,8 +85,8 @@ void MultiColorCorrection::applyCorrection(std::vector<ColorRgb>& ledColors)
|
||||
}
|
||||
ColorRgb& color = ledColors[i];
|
||||
|
||||
color.red = correction->_rgbCorrection.correctionR(color.red);
|
||||
color.green = correction->_rgbCorrection.correctionG(color.green);
|
||||
color.blue = correction->_rgbCorrection.correctionB(color.blue);
|
||||
color.red = correction->_rgbCorrection.adjustmentR(color.red);
|
||||
color.green = correction->_rgbCorrection.adjustmentG(color.green);
|
||||
color.blue = correction->_rgbCorrection.adjustmentB(color.blue);
|
||||
}
|
||||
}
|
||||
|
@@ -411,9 +411,9 @@ void JsonClientConnection::handleServerInfoCommand(const Json::Value &)
|
||||
temperature["id"] = tempId;
|
||||
|
||||
Json::Value & tempValues = temperature["correctionValues"];
|
||||
tempValues.append(colorTemp->_rgbCorrection.getcorrectionR());
|
||||
tempValues.append(colorTemp->_rgbCorrection.getcorrectionG());
|
||||
tempValues.append(colorTemp->_rgbCorrection.getcorrectionB());
|
||||
tempValues.append(colorTemp->_rgbCorrection.getAdjustmentR());
|
||||
tempValues.append(colorTemp->_rgbCorrection.getAdjustmentG());
|
||||
tempValues.append(colorTemp->_rgbCorrection.getAdjustmentB());
|
||||
}
|
||||
|
||||
|
||||
@@ -700,9 +700,9 @@ void JsonClientConnection::handleTemperatureCommand(const Json::Value &message)
|
||||
if (temperature.isMember("correctionValues"))
|
||||
{
|
||||
const Json::Value & values = temperature["correctionValues"];
|
||||
colorTemperature->_rgbCorrection.setcorrectionR(values[0u].asInt());
|
||||
colorTemperature->_rgbCorrection.setcorrectionG(values[1u].asInt());
|
||||
colorTemperature->_rgbCorrection.setcorrectionB(values[2u].asInt());
|
||||
colorTemperature->_rgbCorrection.setAdjustmentR(values[0u].asInt());
|
||||
colorTemperature->_rgbCorrection.setAdjustmentG(values[1u].asInt());
|
||||
colorTemperature->_rgbCorrection.setAdjustmentB(values[2u].asInt());
|
||||
}
|
||||
|
||||
// commit the changes
|
||||
|
@@ -36,8 +36,6 @@ add_library(hyperion-utils
|
||||
${CURRENT_SOURCE_DIR}/HslTransform.cpp
|
||||
${CURRENT_HEADER_DIR}/RgbChannelTransform.h
|
||||
${CURRENT_SOURCE_DIR}/RgbChannelTransform.cpp
|
||||
${CURRENT_HEADER_DIR}/RgbChannelCorrection.h
|
||||
${CURRENT_SOURCE_DIR}/RgbChannelCorrection.cpp
|
||||
${CURRENT_HEADER_DIR}/RgbChannelAdjustment.h
|
||||
${CURRENT_SOURCE_DIR}/RgbChannelAdjustment.cpp
|
||||
|
||||
|
@@ -1,120 +0,0 @@
|
||||
// STL includes
|
||||
#include <cmath>
|
||||
|
||||
// Utils includes
|
||||
#include <utils/RgbChannelCorrection.h>
|
||||
|
||||
RgbChannelCorrection::RgbChannelCorrection() :
|
||||
_correctionR(255),
|
||||
_correctionG(255),
|
||||
_correctionB(255)
|
||||
{
|
||||
initializeMapping();
|
||||
}
|
||||
|
||||
RgbChannelCorrection::RgbChannelCorrection(int correctionR, int correctionG, int correctionB) :
|
||||
_correctionR(correctionR),
|
||||
_correctionG(correctionG),
|
||||
_correctionB(correctionB)
|
||||
{
|
||||
initializeMapping();
|
||||
}
|
||||
|
||||
RgbChannelCorrection::~RgbChannelCorrection()
|
||||
{
|
||||
}
|
||||
|
||||
uint8_t RgbChannelCorrection::getcorrectionR() const
|
||||
{
|
||||
return _correctionR;
|
||||
}
|
||||
|
||||
void RgbChannelCorrection::setcorrectionR(uint8_t correctionR)
|
||||
{
|
||||
_correctionR = correctionR;
|
||||
initializeMapping();
|
||||
}
|
||||
|
||||
uint8_t RgbChannelCorrection::getcorrectionG() const
|
||||
{
|
||||
return _correctionG;
|
||||
}
|
||||
|
||||
void RgbChannelCorrection::setcorrectionG(uint8_t correctionG)
|
||||
{
|
||||
_correctionG = correctionG;
|
||||
initializeMapping();
|
||||
}
|
||||
|
||||
uint8_t RgbChannelCorrection::getcorrectionB() const
|
||||
{
|
||||
return _correctionB;
|
||||
}
|
||||
|
||||
void RgbChannelCorrection::setcorrectionB(uint8_t correctionB)
|
||||
{
|
||||
_correctionB = correctionB;
|
||||
initializeMapping();
|
||||
}
|
||||
|
||||
uint8_t RgbChannelCorrection::correctionR(uint8_t inputR) const
|
||||
{
|
||||
return _mappingR[inputR];
|
||||
}
|
||||
|
||||
uint8_t RgbChannelCorrection::correctionG(uint8_t inputG) const
|
||||
{
|
||||
return _mappingG[inputG];
|
||||
}
|
||||
|
||||
uint8_t RgbChannelCorrection::correctionB(uint8_t inputB) const
|
||||
{
|
||||
return _mappingB[inputB];
|
||||
}
|
||||
|
||||
void RgbChannelCorrection::initializeMapping()
|
||||
{
|
||||
// initialize the mapping
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
int outputR = (i * _correctionR) / 255;
|
||||
if (outputR < -255)
|
||||
{
|
||||
outputR = -255;
|
||||
}
|
||||
else if (outputR > 255)
|
||||
{
|
||||
outputR = 255;
|
||||
}
|
||||
_mappingR[i] = outputR;
|
||||
}
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
int outputG = (i * _correctionG) / 255;
|
||||
if (outputG < -255)
|
||||
{
|
||||
outputG = -255;
|
||||
}
|
||||
else if (outputG > 255)
|
||||
{
|
||||
outputG = 255;
|
||||
}
|
||||
_mappingG[i] = outputG;
|
||||
}
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
int outputB = (i * _correctionB) / 255;
|
||||
if (outputB < -255)
|
||||
{
|
||||
outputB = -255;
|
||||
}
|
||||
else if (outputB > 255)
|
||||
{
|
||||
outputB = 255;
|
||||
}
|
||||
_mappingB[i] = outputB;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -4,28 +4,29 @@
|
||||
// Utils includes
|
||||
#include <utils/RgbChannelTransform.h>
|
||||
|
||||
RgbChannelTransform::RgbChannelTransform() :
|
||||
_threshold(0),
|
||||
_gamma(1.0),
|
||||
_blacklevel(0.0),
|
||||
_whitelevel(1.0)
|
||||
RgbChannelTransform::RgbChannelTransform()
|
||||
{
|
||||
initializeMapping();
|
||||
setTransform(0.0, 1.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
RgbChannelTransform::RgbChannelTransform(double threshold, double gamma, double blacklevel, double whitelevel) :
|
||||
_threshold(threshold),
|
||||
_gamma(gamma),
|
||||
_blacklevel(blacklevel),
|
||||
_whitelevel(whitelevel)
|
||||
RgbChannelTransform::RgbChannelTransform(double threshold, double gamma, double blacklevel, double whitelevel)
|
||||
{
|
||||
initializeMapping();
|
||||
setTransform(threshold, gamma, blacklevel, whitelevel);
|
||||
}
|
||||
|
||||
RgbChannelTransform::~RgbChannelTransform()
|
||||
{
|
||||
}
|
||||
|
||||
void RgbChannelTransform::setTransform(double threshold, double gamma, double blacklevel, double whitelevel)
|
||||
{
|
||||
_threshold = threshold;
|
||||
_gamma = gamma;
|
||||
_blacklevel = blacklevel;
|
||||
_whitelevel = whitelevel;
|
||||
initializeMapping();
|
||||
}
|
||||
|
||||
double RgbChannelTransform::getThreshold() const
|
||||
{
|
||||
return _threshold;
|
||||
@@ -33,8 +34,7 @@ double RgbChannelTransform::getThreshold() const
|
||||
|
||||
void RgbChannelTransform::setThreshold(double threshold)
|
||||
{
|
||||
_threshold = threshold;
|
||||
initializeMapping();
|
||||
setTransform(threshold, _gamma, _blacklevel, _whitelevel);
|
||||
}
|
||||
|
||||
double RgbChannelTransform::getGamma() const
|
||||
@@ -44,8 +44,7 @@ double RgbChannelTransform::getGamma() const
|
||||
|
||||
void RgbChannelTransform::setGamma(double gamma)
|
||||
{
|
||||
_gamma = gamma;
|
||||
initializeMapping();
|
||||
setTransform(_threshold, gamma, _blacklevel, _whitelevel);
|
||||
}
|
||||
|
||||
double RgbChannelTransform::getBlacklevel() const
|
||||
@@ -55,8 +54,7 @@ double RgbChannelTransform::getBlacklevel() const
|
||||
|
||||
void RgbChannelTransform::setBlacklevel(double blacklevel)
|
||||
{
|
||||
_blacklevel = blacklevel;
|
||||
initializeMapping();
|
||||
setTransform(_threshold, _gamma, blacklevel, _whitelevel);
|
||||
}
|
||||
|
||||
double RgbChannelTransform::getWhitelevel() const
|
||||
@@ -66,8 +64,7 @@ double RgbChannelTransform::getWhitelevel() const
|
||||
|
||||
void RgbChannelTransform::setWhitelevel(double whitelevel)
|
||||
{
|
||||
_whitelevel = whitelevel;
|
||||
initializeMapping();
|
||||
setTransform(_threshold, _gamma, _blacklevel, whitelevel);
|
||||
}
|
||||
|
||||
void RgbChannelTransform::initializeMapping()
|
||||
|
Reference in New Issue
Block a user