From 5917b2e4f044c20396ab36ef9fb074b5965b6f9e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 4 Jan 2025 13:24:12 +0100 Subject: [PATCH 1/9] Bump actions/upload-artifact from 4.4.3 to 4.5.0 (#1031) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.4.3 to 4.5.0. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4.4.3...v4.5.0) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/image-builder-from-repo.yml | 2 +- .github/workflows/image-builder.yml | 2 +- .github/workflows/push-master.yml | 12 ++++++------ .github/workflows/upload-to-github-pages.yml | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/image-builder-from-repo.yml b/.github/workflows/image-builder-from-repo.yml index 448461ca9..1729ece56 100644 --- a/.github/workflows/image-builder-from-repo.yml +++ b/.github/workflows/image-builder-from-repo.yml @@ -99,7 +99,7 @@ jobs: echo "image=$IMAGE" >> $GITHUB_OUTPUT # artifact upload will take care of zipping for us - - uses: actions/upload-artifact@v4.4.3 + - uses: actions/upload-artifact@v4.5.0 with: name: ${{ steps.copy.outputs.image }} path: ${{ steps.copy.outputs.image }}.img.xz diff --git a/.github/workflows/image-builder.yml b/.github/workflows/image-builder.yml index 4e33362a2..7b58f4c37 100644 --- a/.github/workflows/image-builder.yml +++ b/.github/workflows/image-builder.yml @@ -121,7 +121,7 @@ jobs: echo "image=$IMAGE" >> $GITHUB_OUTPUT # artifact upload will take care of zipping for us - - uses: actions/upload-artifact@v4.4.3 + - uses: actions/upload-artifact@v4.5.0 with: name: ${{ steps.copy.outputs.image }} path: ${{ steps.copy.outputs.image }}.img diff --git a/.github/workflows/push-master.yml b/.github/workflows/push-master.yml index 211767c94..bf31cde0e 100644 --- a/.github/workflows/push-master.yml +++ b/.github/workflows/push-master.yml @@ -119,7 +119,7 @@ jobs: # Upload artifacts (only on tagged commit) - name: Upload artifacts if: startsWith(github.event.ref, 'refs/tags') && github.event_name != 'pull_request' - uses: actions/upload-artifact@v4.4.3 + uses: actions/upload-artifact@v4.5.0 with: name: release-artifact-${{ matrix.linuxVersion }}-${{ matrix.dockerImage }} path: deploy/Hyper* @@ -127,7 +127,7 @@ jobs: # Upload artifacts from commit - name: Upload artifacts from commit if: (startsWith(github.event.ref, 'refs/tags') != true) && github.event_name != 'pull_request' - uses: actions/upload-artifact@v4.4.3 + uses: actions/upload-artifact@v4.5.0 with: name: Linux-${{ matrix.linuxVersion }}-${{ matrix.dockerImage }}-installer path: | @@ -208,7 +208,7 @@ jobs: # Upload artifacts (only on tagged commit) - name: Upload artifacts if: startsWith(github.event.ref, 'refs/tags') && github.event_name != 'pull_request' - uses: actions/upload-artifact@v4.4.3 + uses: actions/upload-artifact@v4.5.0 with: name: release-artifact-${{ matrix.JOB_RUNNER }} path: build/Hyper*.dmg @@ -216,7 +216,7 @@ jobs: # Upload artifacts from commit - name: Upload artifacts from commit if: (startsWith(github.event.ref, 'refs/tags') != true) && github.event_name != 'pull_request' - uses: actions/upload-artifact@v4.4.3 + uses: actions/upload-artifact@v4.5.0 with: name: Apple_macOS_${{ matrix.NICE_NAME }}_DMG_installer path: build/Hyper*.dmg @@ -307,7 +307,7 @@ jobs: # Upload artifacts (only on tagged commit) - name: Upload artifacts if: startsWith(github.event.ref, 'refs/tags') && github.event_name != 'pull_request' - uses: actions/upload-artifact@v4.4.3 + uses: actions/upload-artifact@v4.5.0 with: name: release-artifact-windows path: build/Hyper* @@ -315,7 +315,7 @@ jobs: # Upload artifacts from commit - name: Upload artifacts from commit if: (startsWith(github.event.ref, 'refs/tags') != true) && github.event_name != 'pull_request' - uses: actions/upload-artifact@v4.4.3 + uses: actions/upload-artifact@v4.5.0 with: name: Windows_x64_setup path: build/Hyper*.exe diff --git a/.github/workflows/upload-to-github-pages.yml b/.github/workflows/upload-to-github-pages.yml index b7530df7e..900bef28e 100644 --- a/.github/workflows/upload-to-github-pages.yml +++ b/.github/workflows/upload-to-github-pages.yml @@ -118,7 +118,7 @@ jobs: rm -r repo/pool/ArchLinux ||: - name: Upload artifacts from commit - uses: actions/upload-artifact@v4.4.3 + uses: actions/upload-artifact@v4.5.0 with: name: release-artifact-${{ matrix.linuxVersion }}-${{ matrix.dockerImage }} path: repo From 564c833621bf4f4dbf3ff68b0fc8031f4fe2dcc2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 4 Jan 2025 13:25:07 +0100 Subject: [PATCH 2/9] Bump softprops/action-gh-release from 2.1.0 to 2.2.0 (#1032) Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 2.1.0 to 2.2.0. - [Release notes](https://github.com/softprops/action-gh-release/releases) - [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md) - [Commits](https://github.com/softprops/action-gh-release/compare/v2.1.0...v2.2.0) --- updated-dependencies: - dependency-name: softprops/action-gh-release dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/push-master.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-master.yml b/.github/workflows/push-master.yml index bf31cde0e..e9fe5cd66 100644 --- a/.github/workflows/push-master.yml +++ b/.github/workflows/push-master.yml @@ -389,7 +389,7 @@ jobs: # create draft release and upload artifacts - name: Create draft release - uses: softprops/action-gh-release@v2.1.0 + uses: softprops/action-gh-release@v2.2.0 with: name: HyperHDR ${{ env.VERSION }} tag_name: ${{ env.TAG }} From 429b0abc58338ad0c8673343c3feb77ab6279e75 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 4 Jan 2025 13:25:54 +0100 Subject: [PATCH 3/9] Bump JamesIves/github-pages-deploy-action from 4.7.1 to 4.7.2 (#1033) Bumps [JamesIves/github-pages-deploy-action](https://github.com/jamesives/github-pages-deploy-action) from 4.7.1 to 4.7.2. - [Release notes](https://github.com/jamesives/github-pages-deploy-action/releases) - [Commits](https://github.com/jamesives/github-pages-deploy-action/compare/v4.7.1...v4.7.2) --- updated-dependencies: - dependency-name: JamesIves/github-pages-deploy-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/upload-to-github-pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload-to-github-pages.yml b/.github/workflows/upload-to-github-pages.yml index 900bef28e..dd1a46901 100644 --- a/.github/workflows/upload-to-github-pages.yml +++ b/.github/workflows/upload-to-github-pages.yml @@ -142,7 +142,7 @@ jobs: - name: Display structure of artifacts run: ls -R repo - name: Deploy the packages - uses: JamesIves/github-pages-deploy-action@v4.7.1 + uses: JamesIves/github-pages-deploy-action@v4.7.2 with: repository-name: awawa-dev/awawa-dev.github.io branch: upload From ddbf6d25b62571b82a68010c36987f03fdd7188c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 4 Jan 2025 13:26:54 +0100 Subject: [PATCH 4/9] Bump actions/cache from 4.1.2 to 4.2.0 (#1034) Bumps [actions/cache](https://github.com/actions/cache) from 4.1.2 to 4.2.0. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v4.1.2...v4.2.0) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/push-master.yml | 8 ++++---- .github/workflows/upload-to-github-pages.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/push-master.yml b/.github/workflows/push-master.yml index e9fe5cd66..f15ce9f23 100644 --- a/.github/workflows/push-master.yml +++ b/.github/workflows/push-master.yml @@ -87,7 +87,7 @@ jobs: # download cache - name: Download ccache files if: env.USE_CACHE == 'true' - uses: actions/cache@v4.1.2 + uses: actions/cache@v4.2.0 with: path: .ccache key: ${{ matrix.linuxVersion }}-${{ matrix.dockerImage }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} @@ -171,7 +171,7 @@ jobs: # Download cache - name: Download ccache files if: env.USE_CACHE == 'true' - uses: actions/cache@v4.1.2 + uses: actions/cache@v4.2.0 with: path: build/.ccache key: macOS-ccache-${{ matrix.NICE_NAME }}-${{ steps.ccache_cache_timestamp.outputs.timestamp }} @@ -238,7 +238,7 @@ jobs: submodules: true - name: Cache Qt - uses: actions/cache@v4.1.2 + uses: actions/cache@v4.2.0 id: cache-qt-windows with: path: ${{ runner.workspace }}/Qt @@ -262,7 +262,7 @@ jobs: # Download cache - name: Download ccache files if: env.USE_CACHE == 'true' - uses: actions/cache@v4.1.2 + uses: actions/cache@v4.2.0 with: path: build/.ccache key: ${{ runner.os }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} diff --git a/.github/workflows/upload-to-github-pages.yml b/.github/workflows/upload-to-github-pages.yml index dd1a46901..e521941f2 100644 --- a/.github/workflows/upload-to-github-pages.yml +++ b/.github/workflows/upload-to-github-pages.yml @@ -84,7 +84,7 @@ jobs: # download cache - name: ccache cache files if: ( env.USE_CACHE == '1' ) - uses: actions/cache@v4.1.2 + uses: actions/cache@v4.2.0 with: path: .ccache key: ${{ matrix.linuxVersion }}-${{ matrix.dockerImage }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} From e4a7f7df41dad8530239c36069ce33891bf1b315 Mon Sep 17 00:00:00 2001 From: Retro <44505837+dankmolot@users.noreply.github.com> Date: Sat, 4 Jan 2025 14:28:09 +0200 Subject: [PATCH 5/9] Pipewire drm workaround fix (#1029) * Pipewire grabber: drm mods workaround * Pipewire grabber: drm mods workaround fix * Change DRM to auto-retry approach --------- Co-authored-by: Awawa <69086569+awawa-dev@users.noreply.github.com> --- .../linux/pipewire/PipewireHandler.cpp | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sources/grabber/linux/pipewire/PipewireHandler.cpp b/sources/grabber/linux/pipewire/PipewireHandler.cpp index 932d3f560..401a672d9 100644 --- a/sources/grabber/linux/pipewire/PipewireHandler.cpp +++ b/sources/grabber/linux/pipewire/PipewireHandler.cpp @@ -49,6 +49,8 @@ #include #include #include +#include + #include #include @@ -780,6 +782,7 @@ void PipewireHandler::captureFrame() else { QVector attribs; + std::vector> eglDrmModWorkaround; attribs << EGL_WIDTH << _frameWidth << EGL_HEIGHT << _frameHeight << EGL_LINUX_DRM_FOURCC_EXT << EGLint(_frameDrmFormat); @@ -798,8 +801,10 @@ void PipewireHandler::captureFrame() if (_frameDrmModifier != DRM_FORMAT_MOD_INVALID) { + int before = attribs.size(); attribs << EGL_DMA_BUF_PLANE_MODIFIER_LO_EXT[i] << EGLint(_frameDrmModifier & 0xffffffff) << EGL_DMA_BUF_PLANE_MODIFIER_HI_EXT[i] << EGLint(_frameDrmModifier >> 32); + eglDrmModWorkaround.push_back(std::pair(before, attribs.size() - 1)); } } @@ -807,6 +812,24 @@ void PipewireHandler::captureFrame() EGLImage eglImage = eglCreateImageKHR(displayEgl, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, (EGLClientBuffer) nullptr, attribs.data()); + if (eglImage == EGL_NO_IMAGE_KHR && eglDrmModWorkaround.size() > 0) + { + // remove drm mods + QVector attribsCopy; + for (int i = 0; i < attribs.size(); i++) + { + attribsCopy.push_back(attribs[i]); + for (const auto& check : eglDrmModWorkaround) + if (i >= check.first && i <= check.second) + { + attribsCopy.pop_back(); + break; + } + } + attribs = attribsCopy; + eglImage = eglCreateImageKHR(displayEgl, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, (EGLClientBuffer) nullptr, attribs.data()); + } + if (eglImage == EGL_NO_IMAGE_KHR) { printf("PipewireEGL: failed to create a texture (reason = '%s')\n", eglErrorToString(eglGetError())); From ea1c59e5073688c5da5f517df0a623bacfbb643e Mon Sep 17 00:00:00 2001 From: Awawa <69086569+awawa-dev@users.noreply.github.com> Date: Sat, 11 Jan 2025 22:46:35 +0100 Subject: [PATCH 6/9] Windows: fix suspend & power off handling (#1039) * Windows: fix system suspend handling * Windows: fix system shutdown handling * Windows: fix system sleep & shutdown handling * Windows: fix system sleep & shutdown handling (part 2) * Revert "Windows: fix system sleep & shutdown handling (part 2)" This reverts commit 57d366d98165027bf4e95798d8d2f472381bca3e. --- include/systray/Systray.h | 1 + sources/base/AccessManager.cpp | 1 + sources/db/AuthTable.cpp | 1 + sources/db/MetaTable.cpp | 1 + sources/led-drivers/net/DriverNetUdpE131.cpp | 1 + .../suspend-handler/SuspendHandlerWindows.cpp | 32 +++++++++++++++++++ sources/systray/SystrayWindows.cpp | 22 +++++++++++++ 7 files changed, 59 insertions(+) diff --git a/include/systray/Systray.h b/include/systray/Systray.h index 5450e9fbd..319b134d2 100644 --- a/include/systray/Systray.h +++ b/include/systray/Systray.h @@ -72,6 +72,7 @@ struct SystrayMenu #ifdef _WIN32 HWND SystrayGetWindow(); + void SystrayAssignQueueHandler(std::function _queueHandler); #endif diff --git a/sources/base/AccessManager.cpp b/sources/base/AccessManager.cpp index 344882557..022ad939c 100644 --- a/sources/base/AccessManager.cpp +++ b/sources/base/AccessManager.cpp @@ -6,6 +6,7 @@ #include #include #include +#include using namespace hyperhdr; diff --git a/sources/db/AuthTable.cpp b/sources/db/AuthTable.cpp index 8fe5281af..77fd7278d 100644 --- a/sources/db/AuthTable.cpp +++ b/sources/db/AuthTable.cpp @@ -1,4 +1,5 @@ #include +#include #include using namespace hyperhdr; diff --git a/sources/db/MetaTable.cpp b/sources/db/MetaTable.cpp index 4be49be1c..ba7259eaa 100644 --- a/sources/db/MetaTable.cpp +++ b/sources/db/MetaTable.cpp @@ -1,5 +1,6 @@ #include #include +#include #include diff --git a/sources/led-drivers/net/DriverNetUdpE131.cpp b/sources/led-drivers/net/DriverNetUdpE131.cpp index 3c3e9fa40..6b77b0e3d 100644 --- a/sources/led-drivers/net/DriverNetUdpE131.cpp +++ b/sources/led-drivers/net/DriverNetUdpE131.cpp @@ -5,6 +5,7 @@ #endif #include +#include // hyperhdr local includes #include diff --git a/sources/suspend-handler/SuspendHandlerWindows.cpp b/sources/suspend-handler/SuspendHandlerWindows.cpp index 5c2644c05..d886c6383 100644 --- a/sources/suspend-handler/SuspendHandlerWindows.cpp +++ b/sources/suspend-handler/SuspendHandlerWindows.cpp @@ -38,12 +38,39 @@ #include #include #include +#include #pragma comment (lib, "WtsApi32.Lib") namespace { HWND handle = nullptr; + SuspendHandler* instance = nullptr; +} + +static void SuspendHandlerQueueHandler(WPARAM wparam) +{ + if (wparam == 0) + { + auto instance = QCoreApplication::instance(); + QUEUE_CALL_0(instance, quit); + } + else if (instance != nullptr) + { + MSG message{}; + QByteArray eventType; + + message.message = WM_POWERBROADCAST; + message.wParam = wparam; + + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + long result = 0; + BLOCK_CALL_3(instance, nativeEventFilter, QByteArray, eventType, void*, &message, long*, &result); + #else + qintptr result = 0; + BLOCK_CALL_3(instance, nativeEventFilter, QByteArray, eventType, void*, &message, qintptr*, &result); + #endif + } } SuspendHandler::SuspendHandler(bool sessionLocker): @@ -51,7 +78,9 @@ SuspendHandler::SuspendHandler(bool sessionLocker): _notifyMonitorHandle(NULL), _sessionLocker(sessionLocker) { + instance = this; handle = SystrayGetWindow(); + SystrayAssignQueueHandler(SuspendHandlerQueueHandler); _notifyHandle = RegisterSuspendResumeNotification(handle, DEVICE_NOTIFY_WINDOW_HANDLE); if (_notifyHandle == NULL) @@ -78,6 +107,9 @@ SuspendHandler::SuspendHandler(bool sessionLocker): SuspendHandler::~SuspendHandler() { + SystrayAssignQueueHandler(nullptr); + instance = nullptr; + if (_notifyHandle != NULL) { UnregisterSuspendResumeNotification(_notifyHandle); diff --git a/sources/systray/SystrayWindows.cpp b/sources/systray/SystrayWindows.cpp index e0004acfd..0d455b1a9 100644 --- a/sources/systray/SystrayWindows.cpp +++ b/sources/systray/SystrayWindows.cpp @@ -46,6 +46,7 @@ namespace std::list icons; std::list bitmaps; ULONG_PTR gdiToken = 0; + std::function queueHandler = nullptr; } HWND SystrayGetWindow() @@ -53,11 +54,30 @@ HWND SystrayGetWindow() return window; } +void SystrayAssignQueueHandler(std::function _queueHandler) +{ + queueHandler = _queueHandler; +} + static LRESULT CALLBACK _tray_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { + case WM_POWERBROADCAST: + if (queueHandler != nullptr && (wparam == PBT_APMSUSPEND || wparam == PBT_APMRESUMESUSPEND || wparam == PBT_POWERSETTINGCHANGE)) + { + queueHandler(wparam); + } + return true; + + case WM_QUERYENDSESSION: + if (queueHandler != nullptr && lparam == 0) + { + queueHandler(0); + } + return false; + case WM_CLOSE: DestroyWindow(hwnd); hwnd = nullptr; @@ -290,6 +310,8 @@ void SystrayUpdate(SystrayMenu *tray) void SystrayClose() { + queueHandler = nullptr; + if (systrayIcon.hIcon != nullptr) { Shell_NotifyIcon(NIM_DELETE, &systrayIcon); From 1fcfcae28132fbbc992ab5ffd7ffac72561f0b47 Mon Sep 17 00:00:00 2001 From: Awawa <69086569+awawa-dev@users.noreply.github.com> Date: Thu, 16 Jan 2025 23:58:17 +0100 Subject: [PATCH 7/9] Lightning-fast builds: use native GA ARM runners (#1057) --- .github/workflows/push-master.yml | 72 ++++++++++++-------- .github/workflows/upload-to-github-pages.yml | 32 ++++++--- 2 files changed, 66 insertions(+), 38 deletions(-) diff --git a/.github/workflows/push-master.yml b/.github/workflows/push-master.yml index f15ce9f23..a73cf57ee 100644 --- a/.github/workflows/push-master.yml +++ b/.github/workflows/push-master.yml @@ -18,58 +18,72 @@ jobs: Linux: name: ${{ matrix.dockerName }} - runs-on: ubuntu-22.04 - + runs-on: ${{ matrix.runner }} strategy: matrix: - linuxVersion: [ bullseye ] - dockerImage: [ x86_64, arm-32bit-armv6l, arm-64bit-aarch64 ] - include: - - dockerImage: x86_64 + include: + - runner: ubuntu-24.04 + dockerImage: x86_64 linuxVersion: bullseye dockerName: Debian Bullseye (x86_64) platform: linux - - dockerImage: x86_64 + - runner: ubuntu-24.04 + dockerImage: x86_64 linuxVersion: bookworm dockerName: Debian Bookworm (x86_64) platform: linux - - dockerImage: x86_64 + - runner: ubuntu-24.04 + dockerImage: x86_64 linuxVersion: jammy dockerName: Ubuntu 22.04 LTS (x86_64) platform: linux - - dockerImage: x86_64 + - runner: ubuntu-24.04 + dockerImage: x86_64 linuxVersion: noble dockerName: Ubuntu 24.04 LTS (x86_64) platform: linux - - dockerImage: x86_64 + - runner: ubuntu-24.04 + dockerImage: x86_64 linuxVersion: oracular dockerName: Ubuntu 24.10 (x86_64) - platform: linux - - dockerImage: arm-32bit-armv6l + platform: linux + - runner: ubuntu-24.04 + dockerImage: x86_64 + linuxVersion: Fedora_41 + dockerName: Fedora 41 (x86_64) + platform: linux + - runner: ubuntu-24.04 + dockerImage: x86_64 + linuxVersion: ArchLinux + dockerName: Arch Linux (x86_64) + platform: linux + - runner: ubuntu-24.04-arm + dockerImage: arm-32bit-armv6l-native linuxVersion: bullseye - dockerName: Debian Bullseye (ARM 32-bit Raspberry Pi OS) + dockerName: Debian Bullseye (native ARM 32-bit Raspberry Pi OS) platform: rpi - - dockerImage: arm-64bit-aarch64 + - runner: ubuntu-24.04-arm + dockerImage: arm-64bit-aarch64-native linuxVersion: bullseye - dockerName: Debian Bullseye (ARM 64-bit Raspberry Pi OS) + dockerName: Debian Bullseye (native ARM 64-bit Raspberry Pi OS) platform: rpi - - dockerImage: arm-32bit-armv6l + - runner: ubuntu-24.04-arm + dockerImage: arm-32bit-armv6l-native linuxVersion: bookworm - dockerName: Debian Bookworm (ARM 32-bit Raspberry Pi OS) + dockerName: Debian Bookworm (native ARM 32-bit Raspberry Pi OS) platform: rpi - - dockerImage: arm-64bit-aarch64 + - runner: ubuntu-24.04-arm + dockerImage: arm-64bit-aarch64-native linuxVersion: bookworm - dockerName: Debian Bookworm (ARM 64-bit Raspberry Pi OS) - platform: rpi - - dockerImage: x86_64 - linuxVersion: Fedora_41 - dockerName: Fedora 41 (x86_64) - platform: linux - - dockerImage: x86_64 - linuxVersion: ArchLinux - dockerName: Arch Linux (x86_64) - platform: linux + dockerName: Debian Bookworm (native ARM 64-bit Raspberry Pi OS) + platform: rpi steps: + # start docker + - name: Wake-up docker + if: matrix.runner == 'ubuntu-24.04-arm' + run: | + sudo systemctl start docker + # checkout - uses: actions/checkout@v4.2.2 with: @@ -326,7 +340,7 @@ jobs: analyze: name: Analyze (CodeQL) - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 if: ${{ vars.USE_CODEQL == 'true' && vars.USE_CODEQL || false }} permissions: diff --git a/.github/workflows/upload-to-github-pages.yml b/.github/workflows/upload-to-github-pages.yml index e521941f2..2f821ceed 100644 --- a/.github/workflows/upload-to-github-pages.yml +++ b/.github/workflows/upload-to-github-pages.yml @@ -15,7 +15,7 @@ jobs: ###################################### Linux: name: ${{ matrix.niceName }} ${{ matrix.linuxVersion }} (${{ matrix.arch }}) - runs-on: ubuntu-22.04 + runs-on: ${{ matrix.runner }} strategy: matrix: @@ -23,43 +23,51 @@ jobs: linuxVersion: [ bullseye, bookworm ] dockerImage: [ x86_64, arm-32bit-armv6l, arm-64bit-aarch64 ] include: - - dockerImage: x86_64 + - runner: ubuntu-24.04 + dockerImage: x86_64 dockerName: Debian (amd64) arch: amd64 platform: linux - - dockerImage: arm-32bit-armv6l + - runner: ubuntu-24.04-arm + dockerImage: arm-32bit-armv6l-native dockerName: Debian (armhf) arch: armhf platform: rpi - - dockerImage: arm-64bit-aarch64 + - runner: ubuntu-24.04-arm + dockerImage: arm-64bit-aarch64-native dockerName: Debian (arm64) arch: arm64 platform: rpi - - dockerImage: x86_64 + - runner: ubuntu-24.04 + dockerImage: x86_64 linuxVersion: ArchLinux dockerName: Arch Linux (x86_64) arch: amd64 platform: linux niceName: "" - - dockerImage: x86_64 + - runner: ubuntu-24.04 + dockerImage: x86_64 linuxVersion: jammy dockerName: Ubuntu 22.04 LTS (x86_64) arch: amd64 platform: linux niceName: Ubuntu 22.04 LTS - - dockerImage: x86_64 + - runner: ubuntu-24.04 + dockerImage: x86_64 linuxVersion: noble dockerName: Ubuntu 24.04 LTS (x86_64) arch: amd64 platform: linux niceName: Ubuntu 24.04 LTS - - dockerImage: x86_64 + - runner: ubuntu-24.04 + dockerImage: x86_64 linuxVersion: oracular dockerName: Ubuntu 24.10 (x86_64) arch: amd64 platform: linux niceName: Ubuntu 24.10 - - dockerImage: x86_64 + - runner: ubuntu-24.04 + dockerImage: x86_64 linuxVersion: Fedora_41 dockerName: Fedora 41 (x86_64) arch: amd64 @@ -67,6 +75,12 @@ jobs: niceName: Fedora 41 steps: + # start docker + - name: Wake-up docker + if: matrix.runner == 'ubuntu-24.04-arm' + run: | + sudo systemctl start docker + # checkout - uses: actions/checkout@v4.2.2 with: From 97b138d760896ebdcae2acfa2855f7a3b3be1ece Mon Sep 17 00:00:00 2001 From: Awawa <69086569+awawa-dev@users.noreply.github.com> Date: Tue, 21 Jan 2025 15:16:13 +0100 Subject: [PATCH 8/9] Fix CodeQL script (#1058) * Add g++ * Update action.yml * Fix fPIC * Fix upload-to-github-pages.yml * Update installers.cmake --- .github/actions/codeql/action.yml | 20 +++++++++++--------- .github/workflows/upload-to-github-pages.yml | 2 +- cmake/installers.cmake | 3 +++ external/CMakeLists.txt | 1 + 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/actions/codeql/action.yml b/.github/actions/codeql/action.yml index 33d98ec7f..fe8d1b479 100644 --- a/.github/actions/codeql/action.yml +++ b/.github/actions/codeql/action.yml @@ -26,27 +26,29 @@ runs: build-essential \ cmake \ git \ + libgtk-3-dev \ + libayatana-appindicator3-dev \ libasound2-dev \ libegl-dev \ - libftdi-dev \ + libflatbuffers-dev flatbuffers-compiler \ + libftdi1-dev \ libgl-dev \ libglvnd-dev \ + liblzma-dev \ libpipewire-0.3-dev \ libqt5serialport5-dev \ - libqt5sql5-sqlite \ - libqt5svg5-dev \ - libqt5x11extras5-dev \ libssl-dev \ + libsystemd-dev \ libturbojpeg0-dev \ libusb-1.0-0-dev \ libx11-dev \ libzstd-dev \ - nasm \ - python3-minimal \ + pkg-config \ qtbase5-dev \ - qdbus-qt5 \ - rpm \ - libsystemd-dev + wget \ + unzip \ + pkg-config \ + python3 - name: Checkout repository uses: actions/checkout@v4 diff --git a/.github/workflows/upload-to-github-pages.yml b/.github/workflows/upload-to-github-pages.yml index 2f821ceed..3275de8cc 100644 --- a/.github/workflows/upload-to-github-pages.yml +++ b/.github/workflows/upload-to-github-pages.yml @@ -21,7 +21,7 @@ jobs: matrix: niceName: [ Debian ] linuxVersion: [ bullseye, bookworm ] - dockerImage: [ x86_64, arm-32bit-armv6l, arm-64bit-aarch64 ] + dockerImage: [ x86_64, arm-32bit-armv6l-native, arm-64bit-aarch64-native ] include: - runner: ubuntu-24.04 dockerImage: x86_64 diff --git a/cmake/installers.cmake b/cmake/installers.cmake index d8f734e1f..90b0b2dae 100644 --- a/cmake/installers.cmake +++ b/cmake/installers.cmake @@ -1,6 +1,9 @@ macro(DeployApple TARGET) if(EXISTS ${TARGET_FILE}) + cmake_policy(PUSH) + cmake_policy(SET CMP0177 NEW) install ( TARGETS hyperhdr DESTINATION "share/.." COMPONENT "HyperHDR" ) + cmake_policy(POP) install(FILES "${PROJECT_SOURCE_DIR}/cmake/osx/Hyperhdr.icns" DESTINATION "hyperhdr.app/Contents/Resources" COMPONENT "HyperHDR") install(FILES "${PROJECT_SOURCE_DIR}/LICENSE" DESTINATION "hyperhdr.app/Contents/Resources" COMPONENT "HyperHDR") diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 4107ef732..23fce071d 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -246,6 +246,7 @@ if ( ENABLE_XZ ) option(BUILD_TESTING "" OFF) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/xz) set_target_properties(liblzma PROPERTIES INTERFACE_INCLUDE_DIRECTORIES $) + set_property(TARGET liblzma PROPERTY POSITION_INDEPENDENT_CODE ON) add_library(LibLZMA::LibLZMA ALIAS liblzma) endif() ENDIF() From 1ce4c3ac991b18445919e66a11f229ed9399f129 Mon Sep 17 00:00:00 2001 From: Awawa <69086569+awawa-dev@users.noreply.github.com> Date: Thu, 23 Jan 2025 18:12:21 +0100 Subject: [PATCH 9/9] Add support for ZSTD compression for all LUT files (#1062) * Add support for XZ compression for all LUTs file * Replace XZ with ZSTD * Update 3RD_PARTY_LICENSES --- .gitmodules | 6 +- 3RD_PARTY_LICENSES | 35 ++++++++++ CMakeLists.txt | 48 ++++---------- HyperhdrConfig.h.in | 4 +- cmake/cmake_modules/Findzstd.cmake | 29 ++++++++ cmake/installers.cmake | 20 +++--- external/CMakeLists.txt | 23 ++++--- external/xz | 1 - external/zstd | 1 + include/utils-xz/utils-xz.h | 7 -- include/utils-zstd/utils-zstd.h | 10 +++ include/utils/LutLoader.h | 4 ++ sources/CMakeLists.txt | 4 +- sources/api/BaseAPI.cpp | 10 +-- sources/api/HyperAPI.cpp | 2 +- sources/hyperhdr/CMakeLists.txt | 8 +-- sources/utils-xz/CMakeLists.txt | 34 ---------- sources/utils-xz/utils-xz.cpp | 85 ------------------------ sources/utils-zstd/CMakeLists.txt | 33 +++++++++ sources/utils-zstd/utils-zstd.cpp | 103 +++++++++++++++++++++++++++++ sources/utils/LutLoader.cpp | 92 ++++++++++++++++++++++---- 21 files changed, 348 insertions(+), 211 deletions(-) create mode 100644 cmake/cmake_modules/Findzstd.cmake delete mode 160000 external/xz create mode 160000 external/zstd delete mode 100644 include/utils-xz/utils-xz.h create mode 100644 include/utils-zstd/utils-zstd.h delete mode 100644 sources/utils-xz/CMakeLists.txt delete mode 100644 sources/utils-xz/utils-xz.cpp create mode 100644 sources/utils-zstd/CMakeLists.txt create mode 100644 sources/utils-zstd/utils-zstd.cpp diff --git a/.gitmodules b/.gitmodules index 712f09c06..d30b0c5d6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,9 +13,6 @@ path = external/qmqtt url = https://github.com/emqx/qmqtt.git ignore = dirty -[submodule "external/xz"] - path = external/xz - url = https://github.com/tukaani-project/xz.git [submodule "external/mdns"] path = external/mdns url = https://github.com/mjansson/mdns.git @@ -34,3 +31,6 @@ [submodule "external/linalg"] path = external/linalg url = https://github.com/sgorsten/linalg.git +[submodule "external/zstd"] + path = external/zstd + url = https://github.com/facebook/zstd.git diff --git a/3RD_PARTY_LICENSES b/3RD_PARTY_LICENSES index 7ad185f6f..66eba44e7 100644 --- a/3RD_PARTY_LICENSES +++ b/3RD_PARTY_LICENSES @@ -3009,3 +3009,38 @@ INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHA FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +============================== + zstd +============================== + +BSD License + +For Zstandard software + +Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name Facebook, nor Meta, nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/CMakeLists.txt b/CMakeLists.txt index c4304e058..7990093a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,7 @@ SET ( DEFAULT_BONJOUR ON ) SET ( DEFAULT_MQTT ON ) SET ( DEFAULT_STATIC_QT_PLUGINS OFF ) SET ( DEFAULT_PRECOMPILED_HEADERS ON ) -SET ( DEFAULT_XZ ON ) +SET ( DEFAULT_ZSTD ON ) SET ( DEFAULT_POWER_MANAGEMENT ON ) SET ( DEFAULT_SYSTRAY ON ) SET ( DEFAULT_SHARED_LIBS ON ) @@ -382,26 +382,6 @@ if(DEFAULT_CEC) endif() endif() -# 7-zip as support -if (WIN32) - # 7zip - cmake_policy(SET CMP0053 NEW) - set(MYENV "PROGRAMFILES(X86)") - - find_program(SEVENZIP_BIN - NAMES 7z 7za - HINTS "${MINGWDIR}" "${MINGWLIBS}/bin" "$MYENV/7-zip" "$ENV{ProgramFiles}/7-zip" "$ENV{ProgramW6432}/7-zip" - PATH_SUFFIXES bin - DOC "7zip executable" - ) - - if (SEVENZIP_BIN) - message( STATUS "7-zip found: ${SEVENZIP_BIN}") - else() - message( FATAL_ERROR "Please install 7-zip") - endif (SEVENZIP_BIN) -endif() - if (CMAKE_CROSSCOMPILING) set ( DEFAULT_USE_SYSTEM_FLATBUFFERS_LIBS OFF ) SET ( DEFAULT_SHARED_LIBS OFF ) @@ -504,8 +484,8 @@ colorMe("ENABLE_PROTOBUF = " ${ENABLE_PROTOBUF}) option(ENABLE_SYSTRAY "Enable SYSTRAY" ${DEFAULT_SYSTRAY}) colorMe("ENABLE_SYSTRAY = " ${ENABLE_SYSTRAY}) -option(ENABLE_XZ "Enable XZ support" ${DEFAULT_XZ}) -colorMe("ENABLE_XZ = " ${ENABLE_XZ}) +option(ENABLE_ZSTD "Enable ZSTD support" ${DEFAULT_ZSTD}) +colorMe("ENABLE_ZSTD = " ${ENABLE_ZSTD}) message( STATUS "\n${CyanColor}BUILD FEATURES${ColorReset}") @@ -547,8 +527,8 @@ SET ( FLATBUFFERS_INSTALL_LIB_DIR ${CMAKE_BINARY_DIR}/flatbuf ) find_package(GitVersion) -if(ENABLE_XZ) - find_package(LibLZMA) +if(ENABLE_ZSTD) + find_package(zstd) endif() # configure a header file to pass some of the CMake settings @@ -694,13 +674,6 @@ if (WIN32) endif() endif() -# Add the source/lib directories -add_subdirectory(external) -add_subdirectory(sources) - -# Add resources directory -add_subdirectory(resources) - # remove generated files on make cleaan too LIST( APPEND GENERATED_QRC ${CMAKE_BINARY_DIR}/WebConfig.qrc @@ -712,12 +685,19 @@ set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${GENERATED_QRC configure_file( "${OUR_CMAKE_MODULES}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) +# Add the source/lib directories +add_subdirectory(external) +add_subdirectory(sources) + +# Add resources directory +add_subdirectory(resources) + # enable make package - no code after this line ! include (${CMAKE_CURRENT_SOURCE_DIR}/cmake/packages.cmake) # external targets -if (WIN32 AND TARGET stb AND TARGET flatbuffers AND TARGET protobuf-nanopb AND TARGET lunasvg AND TARGET flatc AND TARGET qmqtt AND TARGET liblzma AND TARGET sqlite3 AND TARGET precompiled_hyperhdr_headers) - set_target_properties(stb qmqtt flatbuffers protobuf-nanopb lunasvg flatc resources uninstall liblzma sqlite3 precompiled_hyperhdr_headers PROPERTIES FOLDER ExternalLibsTargets) +if (WIN32 AND TARGET stb AND TARGET flatbuffers AND TARGET protobuf-nanopb AND TARGET lunasvg AND TARGET flatc AND TARGET qmqtt AND TARGET libzstd_static AND TARGET libzstd_shared AND TARGET zstd AND TARGET clean-all AND TARGET sqlite3 AND TARGET precompiled_hyperhdr_headers) + set_target_properties(stb qmqtt flatbuffers protobuf-nanopb lunasvg flatc resources uninstall libzstd_static libzstd_shared zstd clean-all sqlite3 precompiled_hyperhdr_headers PROPERTIES FOLDER ExternalLibsTargets) else() set_target_properties(resources uninstall PROPERTIES FOLDER ExternalLibsTargets) endif() diff --git a/HyperhdrConfig.h.in b/HyperhdrConfig.h.in index fcc8b2565..1cfa4f2e5 100644 --- a/HyperhdrConfig.h.in +++ b/HyperhdrConfig.h.in @@ -66,8 +66,8 @@ // Define to enable system qmqtt #cmakedefine USE_SYSTEM_MQTT_LIBS -// Define to enable protobuf -#cmakedefine ENABLE_XZ +// Define to enable zstd +#cmakedefine ENABLE_ZSTD // Define to enable protobuf #cmakedefine ENABLE_PROTOBUF diff --git a/cmake/cmake_modules/Findzstd.cmake b/cmake/cmake_modules/Findzstd.cmake new file mode 100644 index 000000000..44547365d --- /dev/null +++ b/cmake/cmake_modules/Findzstd.cmake @@ -0,0 +1,29 @@ +# - Find zstd +# Find the zstd compression library and includes +# +# ZSTD_INCLUDE_DIRS - where to find zstd.h, etc. +# ZSTD_LIBRARIES - List of libraries when using zstd. +# ZSTD_FOUND - True if zstd found. + +find_path(ZSTD_INCLUDE_DIRS + NAMES zstd.h + HINTS ${zstd_ROOT_DIR}/include) + +find_library(ZSTD_LIBRARIES + NAMES zstd + HINTS ${zstd_ROOT_DIR}/lib) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(zstd DEFAULT_MSG ZSTD_LIBRARIES ZSTD_INCLUDE_DIRS) + +mark_as_advanced( + ZSTD_LIBRARIES + ZSTD_INCLUDE_DIRS) + +if(ZSTD_FOUND AND NOT (TARGET zstd::zstd)) + add_library (zstd::zstd UNKNOWN IMPORTED) + set_target_properties(zstd::zstd + PROPERTIES + IMPORTED_LOCATION ${ZSTD_LIBRARIES} + INTERFACE_INCLUDE_DIRECTORIES ${ZSTD_INCLUDE_DIRS}) +endif() \ No newline at end of file diff --git a/cmake/installers.cmake b/cmake/installers.cmake index 90b0b2dae..378fda4dc 100644 --- a/cmake/installers.cmake +++ b/cmake/installers.cmake @@ -20,9 +20,9 @@ macro(DeployApple TARGET) install(CODE [[ file(INSTALL FILES $ DESTINATION "${CMAKE_INSTALL_PREFIX}/hyperhdr.app/Contents/lib" TYPE SHARED_LIBRARY) ]] COMPONENT "HyperHDR") endif() - # Copy utils-xz - if (USE_SHARED_LIBS AND TARGET utils-xz) - install(CODE [[ file(INSTALL FILES $ DESTINATION "${CMAKE_INSTALL_PREFIX}/hyperhdr.app/Contents/lib" TYPE SHARED_LIBRARY) ]] COMPONENT "HyperHDR") + # Copy utils-zstd + if (USE_SHARED_LIBS AND TARGET utils-zstd) + install(CODE [[ file(INSTALL FILES $ DESTINATION "${CMAKE_INSTALL_PREFIX}/hyperhdr.app/Contents/lib" TYPE SHARED_LIBRARY) ]] COMPONENT "HyperHDR") endif() # Copy utils-image @@ -243,9 +243,9 @@ macro(DeployUnix TARGET) install(CODE [[ file(INSTALL FILES $ DESTINATION "${CMAKE_INSTALL_PREFIX}/share/hyperhdr/lib" TYPE SHARED_LIBRARY) ]] COMPONENT "HyperHDR") endif() - # Copy UTILS-XZ lib - if (TARGET utils-image) - install(CODE [[ file(INSTALL FILES $ DESTINATION "${CMAKE_INSTALL_PREFIX}/share/hyperhdr/lib" TYPE SHARED_LIBRARY) ]] COMPONENT "HyperHDR") + # Copy UTILS-ZSTD lib + if (TARGET utils-zstd) + install(CODE [[ file(INSTALL FILES $ DESTINATION "${CMAKE_INSTALL_PREFIX}/share/hyperhdr/lib" TYPE SHARED_LIBRARY) ]] COMPONENT "HyperHDR") endif() @@ -354,7 +354,7 @@ macro(DeployUnix TARGET) "librt" "libstdc++" "libudev" - "libz" + "libz.so" "libxrender1" "libxi6" "libxext6" @@ -593,9 +593,9 @@ macro(DeployWindows TARGET) install(CODE [[ file(INSTALL FILES $ DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" TYPE SHARED_LIBRARY) ]] COMPONENT "HyperHDR") endif() - # Copy utils-xz - if (USE_SHARED_LIBS AND TARGET utils-xz) - install(CODE [[ file(INSTALL FILES $ DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" TYPE SHARED_LIBRARY) ]] COMPONENT "HyperHDR") + # Copy utils-zstd + if (USE_SHARED_LIBS AND TARGET utils-zstd) + install(CODE [[ file(INSTALL FILES $ DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" TYPE SHARED_LIBRARY) ]] COMPONENT "HyperHDR") endif() # Copy utils-image diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 23fce071d..b4d23ad06 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -237,17 +237,22 @@ if ( ENABLE_MQTT ) endif() #============================================================================= -# XZ +# ZSTD #============================================================================= -if ( ENABLE_XZ ) - if (NOT LIBLZMA_FOUND) - message( STATUS "System library xz could not be found. Using embedded xz library.") - option(BUILD_TESTING "" OFF) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/xz) - set_target_properties(liblzma PROPERTIES INTERFACE_INCLUDE_DIRECTORIES $) - set_property(TARGET liblzma PROPERTY POSITION_INDEPENDENT_CODE ON) - add_library(LibLZMA::LibLZMA ALIAS liblzma) +if ( ENABLE_ZSTD ) + if (NOT zstd_FOUND) + message( STATUS "System library zstd could not be found. Using embedded zstd library.") + if(WIN32) + set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -I${CMAKE_SOURCE_DIR}/external/zstd/lib") + endif() + set(ZSTD_BUILD_TESTS OFF) + set(ZSTD_LEGACY_SUPPORT OFF) + set(ZSTD_BUILD_PROGRAMS OFF) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/zstd/build/cmake) + set_target_properties(libzstd PROPERTIES INTERFACE_INCLUDE_DIRECTORIES $) + set_property(TARGET libzstd PROPERTY POSITION_INDEPENDENT_CODE ON) + add_library(zstd::zstd ALIAS libzstd) endif() ENDIF() diff --git a/external/xz b/external/xz deleted file mode 160000 index 238b4e545..000000000 --- a/external/xz +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 238b4e5458b4bd2cadefb768b8ea7c6b70a191ac diff --git a/external/zstd b/external/zstd new file mode 160000 index 000000000..794ea1b0a --- /dev/null +++ b/external/zstd @@ -0,0 +1 @@ +Subproject commit 794ea1b0afca0f020f4e57b6732332231fb23c70 diff --git a/include/utils-xz/utils-xz.h b/include/utils-xz/utils-xz.h deleted file mode 100644 index ca1f1657d..000000000 --- a/include/utils-xz/utils-xz.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#ifndef _XZ_SHARED_API - #define _XZ_SHARED_API -#endif - -_XZ_SHARED_API const char* DecompressXZ(size_t downloadedDataSize, const uint8_t* downloadedData, const char* fileName); diff --git a/include/utils-zstd/utils-zstd.h b/include/utils-zstd/utils-zstd.h new file mode 100644 index 000000000..c23c31a9b --- /dev/null +++ b/include/utils-zstd/utils-zstd.h @@ -0,0 +1,10 @@ +#pragma once + +#ifndef _ZSTD_SHARED_API + #define _ZSTD_SHARED_API +#endif + +#include + +_ZSTD_SHARED_API const char* DecompressZSTD(size_t downloadedDataSize, const uint8_t* downloadedData, const char* fileName); +_ZSTD_SHARED_API const char* DecompressZSTD(size_t downloadedDataSize, const uint8_t* downloadedData, uint8_t* dest, int destSeek, int destSize); diff --git a/include/utils/LutLoader.h b/include/utils/LutLoader.h index c79f254bc..93bd91dc3 100644 --- a/include/utils/LutLoader.h +++ b/include/utils/LutLoader.h @@ -3,6 +3,7 @@ #ifndef PCH_ENABLED #include #include + #include #endif #include @@ -17,4 +18,7 @@ class LutLoader { MemoryBuffer _lut; void loadLutFile(Logger* _log, PixelFormat color, const QList& files); + private: + bool decompressLut(Logger* _log, QFile& file, int index); + void hasher(int index, Logger* _log); }; diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt index 3ca0cf597..157722a67 100644 --- a/sources/CMakeLists.txt +++ b/sources/CMakeLists.txt @@ -33,8 +33,8 @@ add_subdirectory(utils) add_subdirectory(utils-image) add_subdirectory(webserver) -if(ENABLE_XZ) - add_subdirectory(utils-xz) +if(ENABLE_ZSTD) + add_subdirectory(utils-zstd) endif() diff --git a/sources/api/BaseAPI.cpp b/sources/api/BaseAPI.cpp index 11fd1e5d0..62d582c34 100644 --- a/sources/api/BaseAPI.cpp +++ b/sources/api/BaseAPI.cpp @@ -31,8 +31,8 @@ #include #include -#ifdef ENABLE_XZ - #include +#ifdef ENABLE_ZSTD + #include #endif #ifdef _WIN32 @@ -410,21 +410,21 @@ bool BaseAPI::saveSettings(const QJsonObject& data) QString BaseAPI::installLut(QNetworkReply* reply, QString fileName, int hardware_brightness, int hardware_contrast, int hardware_saturation, qint64 time) { -#ifdef ENABLE_XZ +#ifdef ENABLE_ZSTD QString error = nullptr; if (reply->error() == QNetworkReply::NetworkError::NoError) { QByteArray downloadedData = reply->readAll(); - error = DecompressXZ(downloadedData.size(), reinterpret_cast(downloadedData.data()), QSTRING_CSTR(fileName)); + error = DecompressZSTD(downloadedData.size(), reinterpret_cast(downloadedData.data()), QSTRING_CSTR(fileName)); } else error = "Could not download LUT file"; return error; #else - return "XZ support was disabled in the build configuration"; + return "ZSTD support was disabled in the build configuration"; #endif } diff --git a/sources/api/HyperAPI.cpp b/sources/api/HyperAPI.cpp index b27dd3a69..222a0272f 100644 --- a/sources/api/HyperAPI.cpp +++ b/sources/api/HyperAPI.cpp @@ -568,7 +568,7 @@ void HyperAPI::lutDownloaded(QNetworkReply* reply, int hardware_brightness, int void HyperAPI::handleLutInstallCommand(const QJsonObject& message, const QString& command, int tan) { - const QString& address = QString("%1/lut_lin_tables.3d.xz").arg(message["subcommand"].toString().trimmed()); + const QString& address = QString("%1/lut_lin_tables.3d.zst").arg(message["subcommand"].toString().trimmed()); int hardware_brightness = message["hardware_brightness"].toInt(0); int hardware_contrast = message["hardware_contrast"].toInt(0); int hardware_saturation = message["hardware_saturation"].toInt(0); diff --git a/sources/hyperhdr/CMakeLists.txt b/sources/hyperhdr/CMakeLists.txt index 500c562a5..2e6c2f2eb 100644 --- a/sources/hyperhdr/CMakeLists.txt +++ b/sources/hyperhdr/CMakeLists.txt @@ -54,12 +54,8 @@ else() PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) endif() -if(ENABLE_XZ) - if (LIBLZMA_FOUND) - target_link_libraries(hyperhdr LibLZMA::LibLZMA utils-xz) - else() - target_link_libraries(hyperhdr liblzma utils-xz) - endif() +if(ENABLE_ZSTD) + target_link_libraries(hyperhdr zstd::zstd utils-zstd) endif() if (USE_STATIC_QT_PLUGINS) diff --git a/sources/utils-xz/CMakeLists.txt b/sources/utils-xz/CMakeLists.txt deleted file mode 100644 index 6c2ac048b..000000000 --- a/sources/utils-xz/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -# Define the current source locations - -SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/utils-xz) -SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/sources/utils-xz) - -FILE ( GLOB_RECURSE utils_xz_SOURCES "${CURRENT_HEADER_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) - -if (USE_SHARED_LIBS) - add_library(utils-xz SHARED ${utils_xz_SOURCES}) - if(WIN32) - target_compile_definitions(utils-xz - INTERFACE - "_XZ_SHARED_API=__declspec(dllimport)" - PRIVATE - "_XZ_SHARED_API=__declspec(dllexport)" - ) - else() - target_compile_definitions(utils-xz - INTERFACE - "_XZ_SHARED_API=__attribute__((visibility(\"default\")))" - ) - endif() - install( - TARGETS utils-xz - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" - ) -else() - add_library(utils-xz STATIC ${utils_xz_SOURCES}) -endif() - -target_link_libraries(utils-xz PRIVATE LibLZMA::LibLZMA) -target_include_directories(utils-xz PRIVATE LibLZMA::LibLZMA) - diff --git a/sources/utils-xz/utils-xz.cpp b/sources/utils-xz/utils-xz.cpp deleted file mode 100644 index bd43dd48f..000000000 --- a/sources/utils-xz/utils-xz.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include -#include -#include -#include -#include - -_XZ_SHARED_API const char* DecompressXZ(size_t downloadedDataSize, const uint8_t* downloadedData, const char* fileName) -{ - size_t outSize = 67174456; - std::vector outBuffer; - const char* error = nullptr; - - std::ofstream file; - file.open(fileName, std::ios::out | std::ios::trunc | std::ios::binary); - - if (!file.is_open()) - { - return "Could not open file for writing"; - } - - try - { - outBuffer.resize(outSize); - } - catch(...) - { - error = "Could not allocate buffer"; - } - - if (error == nullptr) - { - const uint32_t flags = LZMA_TELL_UNSUPPORTED_CHECK | LZMA_CONCATENATED; - lzma_stream strm = LZMA_STREAM_INIT; - strm.next_in = downloadedData; - strm.avail_in = downloadedDataSize; - lzma_ret lzmaRet = lzma_stream_decoder(&strm, outSize, flags); - if (lzmaRet == LZMA_OK) - { - do { - strm.next_out = outBuffer.data(); - strm.avail_out = outSize; - lzmaRet = lzma_code(&strm, LZMA_FINISH); - if (lzmaRet == LZMA_MEMLIMIT_ERROR) - { - outSize = lzma_memusage(&strm); - try - { - outBuffer.resize(outSize); - } - catch (...) - { - error = "Could not increase buffer size"; - break; - } - lzma_memlimit_set(&strm, outSize); - strm.avail_out = 0; - } - else if (lzmaRet != LZMA_OK && lzmaRet != LZMA_STREAM_END) - { - error = "LZMA decoder returned error"; - break; - } - else - { - std::streamsize toWrite = static_cast(outSize - strm.avail_out); - file.write(reinterpret_cast(outBuffer.data()), toWrite); - } - } while (strm.avail_out == 0 && lzmaRet != LZMA_STREAM_END); - file.flush(); - } - else - { - error = "Could not initialize LZMA decoder"; - } - - lzma_end(&strm); - } - - file.close(); - - if (error != nullptr) - std::remove(fileName); - - return error; -} diff --git a/sources/utils-zstd/CMakeLists.txt b/sources/utils-zstd/CMakeLists.txt new file mode 100644 index 000000000..c7fa8b096 --- /dev/null +++ b/sources/utils-zstd/CMakeLists.txt @@ -0,0 +1,33 @@ +# Define the current source locations + +SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/utils-zstd) +SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/sources/utils-zstd) + +FILE ( GLOB_RECURSE utils_zstd_SOURCES "${CURRENT_HEADER_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) + +if (USE_SHARED_LIBS) + add_library(utils-zstd SHARED ${utils_zstd_SOURCES}) + if(WIN32) + target_compile_definitions(utils-zstd + INTERFACE + "_ZSTD_SHARED_API=__declspec(dllimport)" + PRIVATE + "_ZSTD_SHARED_API=__declspec(dllexport)" + ) + else() + target_compile_definitions(utils-zstd + INTERFACE + "_ZSTD_SHARED_API=__attribute__((visibility(\"default\")))" + ) + endif() + install( + TARGETS utils-zstd + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +else() + add_library(utils-zstd STATIC ${utils_zstd_SOURCES}) +endif() + +target_link_libraries(utils-zstd PRIVATE zstd::zstd) +target_include_directories(utils-zstd PRIVATE zstd::zstd) \ No newline at end of file diff --git a/sources/utils-zstd/utils-zstd.cpp b/sources/utils-zstd/utils-zstd.cpp new file mode 100644 index 000000000..b5c0068d8 --- /dev/null +++ b/sources/utils-zstd/utils-zstd.cpp @@ -0,0 +1,103 @@ +#include +#include +#include +#include +#include +#include +#include + +_ZSTD_SHARED_API const char* DecompressZSTD(size_t downloadedDataSize, const uint8_t* downloadedData, const char* fileName) +{ + const size_t SINGLE_LUT_SIZE = (static_cast(256 * 256 * 256) * 3); + + size_t outSize = SINGLE_LUT_SIZE / 2; + std::vector outBuffer; + const char* error = nullptr; + + std::ofstream file; + file.open(fileName, std::ios::out | std::ios::trunc | std::ios::binary); + + if (!file.is_open()) + { + return "Could not open file for writing"; + } + + try + { + outBuffer.resize(outSize); + } + catch(...) + { + error = "Could not allocate buffer"; + } + + + if (error == nullptr) + { + ZSTD_DCtx* const dctx = ZSTD_createDCtx(); + + if (dctx == NULL) + { + error = "ZSTD_createDCtx() failed!"; + } + else + { + int total = SINGLE_LUT_SIZE * 3; + ZSTD_inBuffer input = { downloadedData, downloadedDataSize, 0 }; + while (input.pos < input.size) + { + ZSTD_outBuffer outputSeek = { outBuffer.data(), outBuffer.size(), 0 }; + size_t const ret = ZSTD_decompressStream(dctx, &outputSeek, &input); + if (ZSTD_isError(ret) || outputSeek.pos != outBuffer.size() || total < 0) + { + error = "Error during decompression"; + break; + } + else + { + file.write(reinterpret_cast(outBuffer.data()), outBuffer.size()); + } + total -= outBuffer.size(); + } + ZSTD_freeDCtx(dctx); + } + } + + file.close(); + + if (error != nullptr) + std::remove(fileName); + + return error; +} + +_ZSTD_SHARED_API const char* DecompressZSTD(size_t downloadedDataSize, const uint8_t* downloadedData, uint8_t* dest, int destSeek, int destSize) +{ + const char* error = nullptr; + + ZSTD_DCtx* const dctx = ZSTD_createDCtx(); + + if (dctx == NULL) + { + error = "ZSTD_createDCtx() failed!"; + } + else + { + int totalOutput = 0; + ZSTD_inBuffer input = { downloadedData, downloadedDataSize, 0 }; + while (totalOutput <= destSeek && input.pos < input.size) + { + ZSTD_outBuffer outputSeek = { dest, static_cast(destSize), static_cast(0) }; + size_t const ret = ZSTD_decompressStream(dctx, &outputSeek, &input); + if (ZSTD_isError(ret) || outputSeek.pos != destSize) + { + error = "Error during decompression"; + break; + } + totalOutput += outputSeek.pos; + } + ZSTD_freeDCtx(dctx); + } + + return error; +} diff --git a/sources/utils/LutLoader.cpp b/sources/utils/LutLoader.cpp index 53018a8a9..55037f2b2 100644 --- a/sources/utils/LutLoader.cpp +++ b/sources/utils/LutLoader.cpp @@ -24,12 +24,18 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - +#include #include #include #include +#include #include +#ifdef ENABLE_ZSTD + #include +#endif + + namespace { const int LUT_FILE_SIZE = 256 * 256 * 256 *3; const int LUT_MEMORY_ALIGN = 64; @@ -52,17 +58,26 @@ void LutLoader::loadLutFile(Logger* _log, PixelFormat color, const QList(compressedFile.data()), _lut.data(), index, LUT_FILE_SIZE); + #endif + + if (retVal != nullptr && _log) + { + Error(_log, "Error while decompressing LUT: %s", retVal); + } + + if (_log) Info(_log, "Decompression took %f seconds", (InternalClock::nowPrecise() - now) / 1000.0); + + return retVal == nullptr; +} + +void LutLoader::hasher(int index, Logger* _log) +{ + if (_log) + { + auto start = _lut.data(); + auto end = start + _lut.size(); + uint8_t position = 0; + uint16_t fletcher1 = 0; + uint16_t fletcher2 = 0; + uint16_t fletcherExt = 0; + while (start < end) + { + fletcher1 = (fletcher1 + (uint16_t)(*(start))) % 255; + fletcher2 = (fletcher2 + fletcher1) % 255; + fletcherExt = (fletcherExt + (*(start++) ^ (position++))) % 255; + } + Info(_log, "CRC for %i segment: 0x%.2X 0x%.2X 0x%.2X", index, fletcher1, fletcher2, fletcherExt); + } +}