Merge branch 'master' into refactor/led_device

This commit is contained in:
Murat Seker
2020-08-23 21:02:25 +02:00
committed by GitHub
272 changed files with 1711 additions and 1738 deletions

View File

@@ -1,10 +1,9 @@
// Utils includes
#include <utils/ColorArgb.h>
ColorArgb ColorArgb::BLACK = { 255, 0, 0, 0 };
ColorArgb ColorArgb::RED = { 255, 255, 0, 0 };
ColorArgb ColorArgb::GREEN = { 255, 0, 255, 0 };
ColorArgb ColorArgb::BLUE = { 255, 0, 0, 255 };
ColorArgb ColorArgb::YELLOW= { 255, 255, 255, 0 };
ColorArgb ColorArgb::WHITE = { 255, 255, 255, 255 };
const ColorArgb ColorArgb::BLACK = { 255, 0, 0, 0 };
const ColorArgb ColorArgb::RED = { 255, 255, 0, 0 };
const ColorArgb ColorArgb::GREEN = { 255, 0, 255, 0 };
const ColorArgb ColorArgb::BLUE = { 255, 0, 0, 255 };
const ColorArgb ColorArgb::YELLOW = { 255, 255, 255, 0 };
const ColorArgb ColorArgb::WHITE = { 255, 255, 255, 255 };

View File

@@ -1,11 +1,10 @@
// Local includes
#include <utils/ColorBgr.h>
ColorBgr ColorBgr::BLACK = { 0, 0, 0 };
ColorBgr ColorBgr::RED = { 0, 0, 255 };
ColorBgr ColorBgr::GREEN = { 0, 255, 0 };
ColorBgr ColorBgr::BLUE = { 255, 0, 0 };
ColorBgr ColorBgr::YELLOW= { 0, 255, 255 };
ColorBgr ColorBgr::WHITE = { 255, 255, 255 };
const ColorBgr ColorBgr::BLACK = { 0, 0, 0 };
const ColorBgr ColorBgr::RED = { 0, 0, 255 };
const ColorBgr ColorBgr::GREEN = { 0, 255, 0 };
const ColorBgr ColorBgr::BLUE = { 255, 0, 0 };
const ColorBgr ColorBgr::YELLOW = { 0, 255, 255 };
const ColorBgr ColorBgr::WHITE = { 255, 255, 255 };

View File

@@ -1,10 +1,9 @@
// Local includes
#include <utils/ColorRgb.h>
ColorRgb ColorRgb::BLACK = { 0, 0, 0 };
ColorRgb ColorRgb::RED = { 255, 0, 0 };
ColorRgb ColorRgb::GREEN = { 0, 255, 0 };
ColorRgb ColorRgb::BLUE = { 0, 0, 255 };
ColorRgb ColorRgb::YELLOW= { 255, 255, 0 };
ColorRgb ColorRgb::WHITE = { 255, 255, 255 };
const ColorRgb ColorRgb::BLACK = { 0, 0, 0 };
const ColorRgb ColorRgb::RED = { 255, 0, 0 };
const ColorRgb ColorRgb::GREEN = { 0, 255, 0 };
const ColorRgb ColorRgb::BLUE = { 0, 0, 255 };
const ColorRgb ColorRgb::YELLOW = { 255, 255, 0 };
const ColorRgb ColorRgb::WHITE = { 255, 255, 255 };

View File

@@ -1,10 +1,9 @@
// Utils includes
#include <utils/ColorRgba.h>
ColorRgba ColorRgba::BLACK = { 0, 0, 0, 255 };
ColorRgba ColorRgba::RED = { 255, 0, 0, 255 };
ColorRgba ColorRgba::GREEN = { 0, 255, 0, 255 };
ColorRgba ColorRgba::BLUE = { 0, 0, 255, 255 };
ColorRgba ColorRgba::YELLOW= { 255, 255, 0, 255 };
ColorRgba ColorRgba::WHITE = { 255, 255, 255, 255 };
const ColorRgba ColorRgba::BLACK = { 0, 0, 0, 255 };
const ColorRgba ColorRgba::RED = { 255, 0, 0, 255 };
const ColorRgba ColorRgba::GREEN = { 0, 255, 0, 255 };
const ColorRgba ColorRgba::BLUE = { 0, 0, 255, 255 };
const ColorRgba ColorRgba::YELLOW = { 255, 255, 0, 255 };
const ColorRgba ColorRgba::WHITE = { 255, 255, 255, 255 };

View File

@@ -1,10 +1,9 @@
// Local includes
#include <utils/ColorRgbw.h>
ColorRgbw ColorRgbw::BLACK = { 0, 0, 0, 0 };
ColorRgbw ColorRgbw::RED = { 255, 0, 0, 0 };
ColorRgbw ColorRgbw::GREEN = { 0, 255, 0, 0 };
ColorRgbw ColorRgbw::BLUE = { 0, 0, 255, 0 };
ColorRgbw ColorRgbw::YELLOW= { 255, 255, 0, 0 };
ColorRgbw ColorRgbw::WHITE = { 0, 0, 0, 255 };
const ColorRgbw ColorRgbw::BLACK = { 0, 0, 0, 0 };
const ColorRgbw ColorRgbw::RED = { 255, 0, 0, 0 };
const ColorRgbw ColorRgbw::GREEN = { 0, 255, 0, 0 };
const ColorRgbw ColorRgbw::BLUE = { 0, 0, 255, 0 };
const ColorRgbw ColorRgbw::YELLOW = { 255, 255, 0, 0 };
const ColorRgbw ColorRgbw::WHITE = { 0, 0, 0, 255 };

View File

@@ -2,6 +2,11 @@
#include <QColor>
inline uint8_t clamp(int x)
{
return (x<0) ? 0 : ((x>255) ? 255 : uint8_t(x));
}
void ColorSys::rgb2hsl(uint8_t red, uint8_t green, uint8_t blue, uint16_t & hue, float & saturation, float & luminance)
{
QColor color(red,green,blue);
@@ -35,3 +40,15 @@ void ColorSys::hsv2rgb(uint16_t hue, uint8_t saturation, uint8_t value, uint8_t
green = (uint8_t)color.green();
blue = (uint8_t)color.blue();
}
void ColorSys::yuv2rgb(uint8_t y, uint8_t u, uint8_t v, uint8_t &r, uint8_t &g, uint8_t &b)
{
// see: http://en.wikipedia.org/wiki/YUV#Y.27UV444_to_RGB888_conversion
int c = y - 16;
int d = u - 128;
int e = v - 128;
r = clamp((298 * c + 409 * e + 128) >> 8);
g = clamp((298 * c - 100 * d - 208 * e + 128) >> 8);
b = clamp((298 * c + 516 * d + 128) >> 8);
}

View File

@@ -10,13 +10,13 @@
namespace FileUtils {
QString getBaseName(QString sourceFile)
QString getBaseName(const QString& sourceFile)
{
QFileInfo fi(sourceFile);
return fi.fileName();
}
QString getDirName(QString sourceFile)
QString getDirName(const QString& sourceFile)
{
QFileInfo fi(sourceFile);
return fi.path();

View File

@@ -1,4 +1,5 @@
#include "utils/ImageResampler.h"
#include <utils/ColorSys.h>
#include <utils/Logger.h>
ImageResampler::ImageResampler()
@@ -61,11 +62,12 @@ void ImageResampler::processImage(const uint8_t * data, int width, int height, i
int outputWidth = (width - _cropLeft - cropRight - (_horizontalDecimation >> 1) + _horizontalDecimation - 1) / _horizontalDecimation;
int outputHeight = (height - _cropTop - cropBottom - (_verticalDecimation >> 1) + _verticalDecimation - 1) / _verticalDecimation;
if (outputImage.width() != outputWidth || outputImage.height() != outputHeight)
outputImage.resize(outputWidth, outputHeight);
outputImage.resize(outputWidth, outputHeight);
for (int yDest = 0, ySource = _cropTop + (_verticalDecimation >> 1); yDest < outputHeight; ySource += _verticalDecimation, ++yDest)
{
int yOffset = lineLength * ySource;
for (int xDest = 0, xSource = _cropLeft + (_horizontalDecimation >> 1); xDest < outputWidth; xSource += _horizontalDecimation, ++xDest)
{
ColorRgb & rgb = outputImage(xDest, yDest);
@@ -74,25 +76,25 @@ void ImageResampler::processImage(const uint8_t * data, int width, int height, i
{
case PixelFormat::UYVY:
{
int index = lineLength * ySource + (xSource << 1);
int index = yOffset + (xSource << 1);
uint8_t y = data[index+1];
uint8_t u = ((xSource&1) == 0) ? data[index ] : data[index-2];
uint8_t v = ((xSource&1) == 0) ? data[index+2] : data[index ];
yuv2rgb(y, u, v, rgb.red, rgb.green, rgb.blue);
ColorSys::yuv2rgb(y, u, v, rgb.red, rgb.green, rgb.blue);
}
break;
case PixelFormat::YUYV:
{
int index = lineLength * ySource + (xSource << 1);
int index = yOffset + (xSource << 1);
uint8_t y = data[index];
uint8_t u = ((xSource&1) == 0) ? data[index+1] : data[index-1];
uint8_t v = ((xSource&1) == 0) ? data[index+3] : data[index+1];
yuv2rgb(y, u, v, rgb.red, rgb.green, rgb.blue);
ColorSys::yuv2rgb(y, u, v, rgb.red, rgb.green, rgb.blue);
}
break;
case PixelFormat::BGR16:
{
int index = lineLength * ySource + (xSource << 1);
int index = yOffset + (xSource << 1);
rgb.blue = (data[index] & 0x1f) << 3;
rgb.green = (((data[index+1] & 0x7) << 3) | (data[index] & 0xE0) >> 5) << 2;
rgb.red = (data[index+1] & 0xF8);
@@ -100,7 +102,7 @@ void ImageResampler::processImage(const uint8_t * data, int width, int height, i
break;
case PixelFormat::BGR24:
{
int index = lineLength * ySource + (xSource << 1) + xSource;
int index = yOffset + (xSource << 1) + xSource;
rgb.blue = data[index ];
rgb.green = data[index+1];
rgb.red = data[index+2];
@@ -108,7 +110,7 @@ void ImageResampler::processImage(const uint8_t * data, int width, int height, i
break;
case PixelFormat::RGB32:
{
int index = lineLength * ySource + (xSource << 2);
int index = yOffset + (xSource << 2);
rgb.red = data[index ];
rgb.green = data[index+1];
rgb.blue = data[index+2];
@@ -116,7 +118,7 @@ void ImageResampler::processImage(const uint8_t * data, int width, int height, i
break;
case PixelFormat::BGR32:
{
int index = lineLength * ySource + (xSource << 2);
int index = yOffset + (xSource << 2);
rgb.blue = data[index ];
rgb.green = data[index+1];
rgb.red = data[index+2];
@@ -133,20 +135,3 @@ void ImageResampler::processImage(const uint8_t * data, int width, int height, i
}
}
}
uint8_t ImageResampler::clamp(int x)
{
return (x<0) ? 0 : ((x>255) ? 255 : uint8_t(x));
}
void ImageResampler::yuv2rgb(uint8_t y, uint8_t u, uint8_t v, uint8_t &r, uint8_t &g, uint8_t &b)
{
// see: http://en.wikipedia.org/wiki/YUV#Y.27UV444_to_RGB888_conversion
int c = y - 16;
int d = u - 128;
int e = v - 128;
r = clamp((298 * c + 409 * e + 128) >> 8);
g = clamp((298 * c - 100 * d - 208 * e + 128) >> 8);
b = clamp((298 * c + 516 * d + 128) >> 8);
}

View File

@@ -114,7 +114,7 @@ Logger::LogLevel Logger::getLogLevel(const QString & name)
return static_cast<Logger::LogLevel>(int(GLOBAL_MIN_LOG_LEVEL));
}
Logger* log = Logger::getInstance(name);
const Logger* log = Logger::getInstance(name);
return log->getMinLevel();
}

View File

@@ -48,7 +48,7 @@ bool NetOrigin::isLocalAddress(const QHostAddress& address, const QHostAddress&
return true;
}
void NetOrigin::handleSettingsUpdate(const settings::type& type, const QJsonDocument& config)
void NetOrigin::handleSettingsUpdate(settings::type type, const QJsonDocument& config)
{
if(type == settings::NETWORK)
{

View File

@@ -43,7 +43,7 @@ void Profiler::initLogger()
_logger = Logger::getInstance("PROFILER", Logger::DEBUG);
}
void Profiler::TimerStart(const QString timerName, const char* sourceFile, const char* func, unsigned int line)
void Profiler::TimerStart(const QString& timerName, const char* sourceFile, const char* func, unsigned int line)
{
std::pair<std::map<QString,StopWatchItem>::iterator,bool> ret;
Profiler::initLogger();
@@ -71,7 +71,7 @@ void Profiler::TimerStart(const QString timerName, const char* sourceFile, const
}
void Profiler::TimerGetTime(const QString timerName, const char* sourceFile, const char* func, unsigned int line)
void Profiler::TimerGetTime(const QString& timerName, const char* sourceFile, const char* func, unsigned int line)
{
std::map<QString,StopWatchItem>::iterator ret = GlobalProfilerMap.find(timerName);
Profiler::initLogger();

View File

@@ -5,7 +5,7 @@
namespace RGBW {
WhiteAlgorithm stringToWhiteAlgorithm(QString str)
WhiteAlgorithm stringToWhiteAlgorithm(const QString& str)
{
if (str == "subtract_minimum") return WhiteAlgorithm::SUBTRACT_MINIMUM;
if (str == "sub_min_warm_adjust") return WhiteAlgorithm::SUB_MIN_WARM_ADJUST;
@@ -14,7 +14,7 @@ WhiteAlgorithm stringToWhiteAlgorithm(QString str)
return WhiteAlgorithm::INVALID;
}
void Rgb_to_Rgbw(ColorRgb input, ColorRgbw * output, const WhiteAlgorithm algorithm)
void Rgb_to_Rgbw(ColorRgb input, ColorRgbw * output, WhiteAlgorithm algorithm)
{
switch (algorithm)
{

View File

@@ -166,7 +166,7 @@ void QJsonSchemaChecker::setMessage(const QString & message)
_messages.append(_currentPath.join("") +": "+message);
}
const QStringList & QJsonSchemaChecker::getMessages() const
QStringList QJsonSchemaChecker::getMessages() const
{
return _messages;
}