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:
redPanther 2016-07-04 00:43:41 +02:00 committed by brindosch
parent 921f164b26
commit 78eaaa2e84
12 changed files with 46 additions and 226 deletions

View File

@ -8,6 +8,10 @@ IF ( POLICY CMP0026 )
CMAKE_POLICY( SET CMP0026 OLD )
ENDIF()
IF ( POLICY CMP0043 )
CMAKE_POLICY( SET CMP0043 OLD )
ENDIF()
SET ( HYPERION_VERSION_STABLE OFF )
SET ( HYPERION_VERSION_MAJOR 2 )
SET ( HYPERION_VERSION_MINOR 0 )

View File

@ -4,7 +4,7 @@
#include <string>
// Utils includes
#include <utils/RgbChannelCorrection.h>
#include <utils/RgbChannelAdjustment.h>
class ColorCorrection
{
@ -14,5 +14,5 @@ public:
std::string _id;
/// The RGB correction
RgbChannelCorrection _rgbCorrection;
RgbChannelAdjustment _rgbCorrection;
};

View File

@ -235,7 +235,7 @@ public:
static HsvTransform * createHsvTransform(const Json::Value & hsvConfig);
static HslTransform * createHslTransform(const Json::Value & hslConfig);
static RgbChannelTransform * createRgbChannelTransform(const Json::Value& colorConfig);
static RgbChannelCorrection * createRgbChannelCorrection(const Json::Value& colorConfig);
static RgbChannelAdjustment * createRgbChannelCorrection(const Json::Value& colorConfig);
static RgbChannelAdjustment * createRgbChannelAdjustment(const Json::Value& colorConfig, const RgbChannel color);
static LedDevice * createColorSmoothing(const Json::Value & smoothingConfig, LedDevice * ledDevice);

View File

@ -20,15 +20,15 @@ public:
/// Destructor
~RgbChannelAdjustment();
/// @return The current adjustR value
uint8_t getAdjustmentR() const;
/// setAdjustment RGB
/// @param adjustR
/// @param adjustG
/// @param adjustB
void setAdjustment(uint8_t adjustR, uint8_t adjustG, uint8_t adjustB);
/// @return The current adjustR value
uint8_t getAdjustmentR() const;
/// @param threshold New adjustR value
void setAdjustmentR(uint8_t adjustR);

View File

@ -1,66 +0,0 @@
#pragma once
// STL includes
#include <cstdint>
/// Correction for a single color byte value
/// All configuration values are unsigned int and assume the color value to be between 0 and 255
class RgbChannelCorrection
{
public:
/// Default constructor
RgbChannelCorrection();
/// Constructor
/// @param correctionR
/// @param correctionG
/// @param correctionB
RgbChannelCorrection(int correctionR, int correctionG, int correctionB);
/// Destructor
~RgbChannelCorrection();
/// @return The current correctionR value
uint8_t getcorrectionR() const;
/// @param threshold New correctionR value
void setcorrectionR(uint8_t correctionR);
/// @return The current correctionG value
uint8_t getcorrectionG() const;
/// @param gamma New correctionG value
void setcorrectionG(uint8_t correctionG);
/// @return The current correctionB value
uint8_t getcorrectionB() const;
/// @param blacklevel New correctionB value
void setcorrectionB(uint8_t correctionB);
/// Transform the given array value
/// @param input The input color bytes
/// @return The corrected byte value
uint8_t correctionR(uint8_t inputR) const;
uint8_t correctionG(uint8_t inputG) const;
uint8_t correctionB(uint8_t inputB) const;
private:
/// (re)-initilize the color mapping
void initializeMapping();
private:
/// The correction of R channel
int _correctionR;
/// The correction of G channel
int _correctionG;
/// The correction of B channel
int _correctionB;
/// The mapping from input color to output color
int _mappingR[256];
int _mappingG[256];
int _mappingB[256];
};

View File

@ -28,6 +28,13 @@ public:
/// 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;

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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

View File

@ -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

View File

@ -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;
}
}

View File

@ -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()