Skip to content

Commit 00b0611

Browse files
awawa-devAstaRom
andauthored
Automatic tone mapping (#996)
* Define structures * More structures * Add UI for automatic tone mapping settings * Better explanation * Add automatic tone mapping config handler * Add communication to video processor * Implementation of automatic tone mapping control * Automatic tone mapping control: add timeout option for turning tone mapping off * Update language file's (#998) * Update changelog --------- Co-authored-by: Roman Astafev <[email protected]>
1 parent 5e7ca6c commit 00b0611

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+781
-44
lines changed

CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
1+
- Automatic tone mapping (#998), HyperHDR v21
2+
- Add Ubuntu 24.10 and Fedora 41 (#1001), HyperHDR v21
3+
- Add support for "unicam image" RPi HDMI capture card and UYVY format (#889), HyperHDR v21
4+
- Breaking change: remove LUT from installer and create it dynamically (#994), HyperHDR v21
5+
- Fix macOS 15 dark theme menu icons (#988), HyperHDR v21
6+
- Add P010 HDR10 video format support (2024-11-24) (#968), HyperHDR v21
7+
- DirectX multi-monitor support (#966), HyperHDR v21
8+
- macOS 15 sequoia: migrate to ScreenCaptureKit (#984), HyperHDR v21
9+
- Add Skydimo "support" (#985), HyperHDR v21
10+
- New LUT calibration based on mp4 test videos (part I) (#896), HyperHDR v21
11+
- feat: updated rpi_ws281x submodule, thanks @andreasvikke (#974), HyperHDR v21
12+
- DX grabber: stick to user specified device selection (#961), HyperHDR v21
13+
- Fix LED colors adjustments by configuration name (#956), HyperHDR v21
14+
- Add autoresume feature for the macOS software grabber (#879), HyperHDR v21
15+
- Add NV12 image format support for flatbuffers (#920), HyperHDR v21
16+
- Update language file's Thanks @AstaRom (#883, #923, #998), HyperHDR v21
17+
- Update flatbuffers to v24.3.25 (#875), HyperHDR v21
18+
- Add cache_cleaner for Github Action (#910), HyperHDR v21
19+
- New build.sh script for the HyperHDR build process (#904), HyperHDR v21
20+
- Remove Alsa libs from CMake recipe, HyperHDR v21
21+
- Remove more unnecessary libraries from installers, HyperHDR v21
22+
- Remove libasound from installers, HyperHDR v21
23+
- Fix restoring calibration settings (#874), HyperHDR v21
24+
- Reorganize HyperHDR libs (#887), HyperHDR v21
25+
- Fix macOS image alignment (#838), HyperHDR v21
26+
- Remove hyperhdr-remote app. Reason: #856, HyperHDR v21
27+
- Refactoring of the FlatBuffers client and server (#880), HyperHDR v21
28+
- Remove mbedtls. Use OpenSSL (#877), HyperHDR v21
29+
- Removal of QT SQL. Migrate to the SQLite library. (#872), HyperHDR v21
30+
- New smoothing option for sound effects, fix ArchLinux installer, refactoring of the smoothing module and music effects (#871), HyperHDR v21
31+
- Removal of QT D-Bus, switch to sdbus-cpp (#864), HyperHDR v21
32+
- Dependency reductions: removal of heavy QT Gui lib (#861), HyperHDR v21
33+
- Fix DirectX capturing after new Systray changes, HyperHDR v21
34+
- New independed systray. Dependency reductions thanks to removal of QWidget (#852), HyperHDR v21
35+
- Fix: lut calibration for grabberless builds (#840), HyperHDR v21
36+
- Fix: close LED device on correct Thread (#803), HyperHDR v21
137
- Fedora uses xz as the package name, not xz-utils #771 Thanks @hsmalley (v20 beta2 🆕)
238
- Fix LUT loading bug to reduce memory usage by 96MB #766 (v20 beta2 🆕)
339
- Fix background music effect #761 (v20 beta2 🆕)

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ Open source ambient lighting implementation for television and music sets based
1717
* Support for USB grabbers under Linux, Windows 10, macOS
1818
* Pipewire/Portal hardware-accelerated screen capturer for Linux/Wayland
1919
* DirectX screen grabber with pixel and vertex shader processing acceleration for Windows 10/11
20-
* DirectX screen grabber supports native Windows HDR modes like DXGI_FORMAT_R16G16B16A16_FLOAT
20+
* DirectX screen grabber supports native Windows HDR modes like DXGI_FORMAT_R16G16B16A16_FLOAT and multi-monitor ( :new: HyperHDR v21)
2121
* Dynamic video cache buffers. Now Rpi can process even 1080p120 NV12 stream without any size decimation
2222
* Built-in audio visualization effects using **spectrum analysis**
2323
* MQTT support for IoT
2424
* Entertainment API v2: per-channel support for Philips Gradient Strip and others
25-
* Automatic LUT calibration detects grabber model specific properties for the best quality of HDR/SDR
25+
* Automatic LUT calibration detects grabber model specific properties for the best quality of HDR/SDR using MP4 test files ( :new: HyperHDR v21)
2626
* Optimized multi-instances. You can use for example your TV LED strip and multiple WLED or Philips Hue light sources.
2727
* Built-in latency benchmark for USB grabbers
28+
* support for high-quality P010 video format ( :new: HyperHDR v21)
2829
* easy LED strip geometry editing process, automatic or manual with mouse and context menu per single LED
2930
* Automatic signal detection with smart learning capability for USB grabbers
3031
* SK6812 RGBW: advanced calibration of the white color channel for [HyperSerialEsp8266](https://github.com/awawa-dev/HyperSerialEsp8266), [HyperSerialESP32](https://github.com/awawa-dev/HyperSerialESP32), [HyperSPI](https://github.com/awawa-dev/HyperSPI), [HyperSerialPico](https://github.com/awawa-dev/HyperSerialPico)

cmake/packages.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ endif()
151151
# OSX dmg generator
152152
if ( APPLE )
153153
SET ( CPACK_GENERATOR "DragNDrop")
154-
SET ( CPACK_DMG_FORMAT "UDBZ" )
154+
SET ( CPACK_DMG_FORMAT "ULMO" )
155155

156156
unset(CPACK_PACKAGE_ICON)
157157
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/cmake/osx/Hyperhdr.icns")
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/* AutomaticToneMapping.h
2+
*
3+
* MIT License
4+
*
5+
* Copyright (c) 2020-2024 awawa-dev
6+
*
7+
* Project homesite: https://github.com/awawa-dev/HyperHDR
8+
*
9+
* Permission is hereby granted, free of charge, to any person obtaining a copy
10+
* of this software and associated documentation files (the "Software"), to deal
11+
* in the Software without restriction, including without limitation the rights
12+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
* copies of the Software, and to permit persons to whom the Software is
14+
* furnished to do so, subject to the following conditions:
15+
*
16+
* The above copyright notice and this permission notice shall be included in all
17+
* copies or substantial portions of the Software.
18+
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
* SOFTWARE.
26+
*/
27+
28+
#pragma once
29+
30+
#ifndef PCH_ENABLED
31+
#endif
32+
33+
#include <utils/Logger.h>
34+
35+
class AutomaticToneMapping
36+
{
37+
public:
38+
struct ToneMappingThresholds;
39+
40+
AutomaticToneMapping();
41+
42+
AutomaticToneMapping* prepare();
43+
void finilize();
44+
void setConfig(bool enabled, const ToneMappingThresholds& newConfig, int timeInSec, int timeToDisableInMSec);
45+
void setToneMapping(bool enabled);
46+
47+
constexpr uint8_t checkY(uint8_t y)
48+
{
49+
if (y > _running.y) _running.y = y;
50+
return y;
51+
}
52+
53+
constexpr uint8_t checkU(uint8_t u)
54+
{
55+
if (u > _running.u) _running.u = u;
56+
return u;
57+
}
58+
59+
constexpr uint8_t checkV(uint8_t v)
60+
{
61+
if (v > _running.v) _running.v = v;
62+
return v;
63+
}
64+
65+
struct ToneMappingThresholds {
66+
uint8_t y;
67+
uint8_t u;
68+
uint8_t v;
69+
};
70+
71+
private:
72+
bool _enabled;
73+
int _timeInSec;
74+
int _timeToDisableInMSec;
75+
76+
ToneMappingThresholds _config, _running;
77+
78+
bool _modeSDR;
79+
long _startedTime;
80+
long _endingTime;
81+
Logger* _log;
82+
83+
};

include/base/Grabber.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <utils/LutLoader.h>
2121
#include <base/DetectionManual.h>
2222
#include <base/DetectionAutomatic.h>
23+
#include <base/AutomaticToneMapping.h>
2324
#include <performance-counters/PerformanceCounters.h>
2425

2526
#if defined(_WIN32) || defined(WIN32)
@@ -125,6 +126,9 @@ class Grabber : public DetectionAutomatic, public DetectionManual, protected Lut
125126

126127
QString getConfigurationPath();
127128

129+
void setAutomaticToneMappingConfig(bool enabled, const AutomaticToneMapping::ToneMappingThresholds& newConfig, int timeInSec, int timeToDisableInMSec);
130+
void setAutoToneMappingCurrentStateEnabled(bool enabled);
131+
128132
struct DevicePropertiesItem
129133
{
130134
int x, y, fps, fps_a, fps_b, input;
@@ -272,6 +276,7 @@ public slots:
272276
bool _signalDetectionEnabled;
273277
bool _signalAutoDetectionEnabled;
274278
QSemaphore _synchro;
279+
AutomaticToneMapping _automaticToneMapping;
275280
};
276281

277282
bool sortDevicePropertiesItem(const Grabber::DevicePropertiesItem& v1, const Grabber::DevicePropertiesItem& v2);

include/grabber/linux/v4l2/V4L2Worker.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <utils/PixelFormat.h>
1111
#include <base/Grabber.h>
1212
#include <utils/Components.h>
13+
#include <base/AutomaticToneMapping.h>
1314

1415
#include <turbojpeg.h>
1516

@@ -32,7 +33,7 @@ class V4L2Worker : public QThread
3233
unsigned __cropBottom, unsigned __cropRight,
3334
quint64 __currentFrame, qint64 __frameBegin,
3435
int __hdrToneMappingEnabled, uint8_t* __lutBuffer,
35-
bool __qframe, bool __directAccess, QString __deviceName);
36+
bool __qframe, bool __directAccess, QString __deviceName, AutomaticToneMapping* __automaticToneMapping);
3637

3738
void startOnThisThread();
3839
void run() override;
@@ -76,6 +77,7 @@ class V4L2Worker : public QThread
7677
bool _qframe;
7778
bool _directAccess;
7879
QString _deviceName;
80+
AutomaticToneMapping* _automaticToneMapping;
7981
};
8082

8183
class V4L2WorkerManager : public QObject

include/grabber/osx/AVF/AVFWorker.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <utils/PixelFormat.h>
1818
#include <base/Grabber.h>
1919
#include <utils/Components.h>
20+
#include <base/AutomaticToneMapping.h>
2021

2122

2223

@@ -38,7 +39,7 @@ class AVFWorker : public QThread
3839
unsigned __cropBottom, unsigned __cropRight,
3940
quint64 __currentFrame, qint64 __frameBegin,
4041
int __hdrToneMappingEnabled, uint8_t* __lutBuffer, bool __qframe,
41-
bool __directAccess, QString __deviceName);
42+
bool __directAccess, QString __deviceName, AutomaticToneMapping* __automaticToneMapping);
4243

4344
void startOnThisThread();
4445
void run() override;
@@ -78,6 +79,7 @@ class AVFWorker : public QThread
7879
bool _qframe;
7980
bool _directAccess;
8081
QString _deviceName;
82+
AutomaticToneMapping* _automaticToneMapping;
8183
};
8284

8385
class AVFWorkerManager : public QObject

include/grabber/windows/MF/MFWorker.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <utils/PixelFormat.h>
88
#include <base/Grabber.h>
99
#include <utils/Components.h>
10+
#include <base/AutomaticToneMapping.h>
1011

1112
#include <turbojpeg.h>
1213

@@ -27,7 +28,7 @@ class MFWorker : public QThread
2728
unsigned __cropBottom, unsigned __cropRight,
2829
quint64 __currentFrame, qint64 __frameBegin,
2930
int __hdrToneMappingEnabled, uint8_t* __lutBuffer, bool __qframe,
30-
bool __directAccess, QString __deviceName);
31+
bool __directAccess, QString __deviceName, AutomaticToneMapping* __automaticToneMapping);
3132

3233
void startOnThisThread();
3334
void run() override;
@@ -69,6 +70,7 @@ class MFWorker : public QThread
6970
bool _qframe;
7071
bool _directAccess;
7172
QString _deviceName;
73+
AutomaticToneMapping* _automaticToneMapping;
7274
};
7375

7476
class MFWorkerManager : public QObject

include/lut-calibrator/BestResult.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ struct BestResult
8080
double upYLimit = 0;
8181
double downYLimit = 0;
8282
double yShift = 0;
83+
byte3 yuvRange = {};
8384
bool isSourceP010 = false;
8485
} signal;
8586

@@ -124,6 +125,7 @@ struct BestResult
124125
out << "bestResult.signal.yShift = " << std::to_string(signal.yShift) << ";" << std::endl;
125126
out << "bestResult.signal.isSourceP010 = " << std::to_string(signal.isSourceP010) << ";" << std::endl;
126127
out << "bestResult.minError = " << std::to_string(std::round(minError * 100.0) / 30000.0) << ";" << std::endl;
128+
out << "bestResult.signal.yuvRange = byte3{ " << std::to_string(signal.yuvRange[0]) << ", " << std::to_string(signal.yuvRange[1]) << ", " << std::to_string(signal.yuvRange[2]) << "};" << std::endl;
127129
out << "*/" << std::endl;
128130
}
129131
};

include/lut-calibrator/BoardUtils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ namespace BoardUtils
8484
double _yShift = 0;
8585
double _downYLimit = 0;
8686
double _upYLimit = 0;
87+
byte3 _rangeYUV = {};
8788

8889
public:
8990
CapturedColors() = default;
@@ -96,7 +97,7 @@ namespace BoardUtils
9697
bool areAllCaptured();
9798
void finilizeBoard();
9899
static void correctYRange(double3& yuv, double yRange, double upYLimit, double downYLimit, double yShift);
99-
void getSignalParams(double& yRange, double& upYLimit, double& downYLimit, double& yShift);
100+
void getSignalParams(double& yRange, double& upYLimit, double& downYLimit, double& yShift, byte3& rangeYUV);
100101
void setCaptured(int index);
101102
void setRange(YuvConverter::COLOR_RANGE range);
102103
YuvConverter::COLOR_RANGE getRange() const;

0 commit comments

Comments
 (0)