From aac8c81ebe406eae972e24a1a329058966df6420 Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Tue, 2 Apr 2024 20:42:36 +0200 Subject: [PATCH 1/6] use libframeutil instead of copied code --- .github/workflows/libdmdutil.yml | 2 +- CMakeLists.txt | 1 - platforms/android/arm64-v8a/external.sh | 4 +- platforms/ios/arm64/external.sh | 3 +- platforms/linux/aarch64/external.sh | 3 +- platforms/linux/x64/external.sh | 3 +- platforms/macos/arm64/external.sh | 3 +- platforms/macos/x64/external.sh | 3 +- platforms/tvos/arm64/external.sh | 3 +- platforms/win/x64/external.sh | 3 +- platforms/win/x86/external.sh | 3 +- src/DMD.cpp | 30 +- src/FrameUtil.cpp | 450 ------------------------ src/FrameUtil.h | 46 --- src/PixelcadeDMD.cpp | 12 +- 15 files changed, 38 insertions(+), 531 deletions(-) delete mode 100644 src/FrameUtil.cpp delete mode 100644 src/FrameUtil.h diff --git a/.github/workflows/libdmdutil.yml b/.github/workflows/libdmdutil.yml index b9ee679..1342d7c 100644 --- a/.github/workflows/libdmdutil.yml +++ b/.github/workflows/libdmdutil.yml @@ -208,7 +208,7 @@ jobs: zip -r libdmdutil-${{ needs.version.outputs.tag }}-win-x64.zip libdmdutil-${{ needs.version.outputs.tag }}-win-x64 zip -r libdmdutil-${{ needs.version.outputs.tag }}-win-x86.zip libdmdutil-${{ needs.version.outputs.tag }}-win-x86 - name: Release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') with: draft: true diff --git a/CMakeLists.txt b/CMakeLists.txt index 41fe874..5269001 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,7 +70,6 @@ set(DMDUTIL_SOURCES src/ConsoleDMD.cpp src/Logger.cpp src/AlphaNumeric.cpp - src/FrameUtil.cpp src/Serum.cpp ) diff --git a/platforms/android/arm64-v8a/external.sh b/platforms/android/arm64-v8a/external.sh index bc6d03c..75911f3 100755 --- a/platforms/android/arm64-v8a/external.sh +++ b/platforms/android/arm64-v8a/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=42d95ed6f1fe2065ecbd247502d177d7e5eb7e4c +LIBZEDMD_SHA=340d0fbe0afbaf5583303599473bcc9ddc7bed0f LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c @@ -22,6 +22,7 @@ echo " LIBZEDMD_SHA: ${LIBZEDMD_SHA}" echo " LIBSERUM_SHA: ${LIBSERUM_SHA}" echo " SOCKPP_SHA: ${SOCKPP_SHA}" echo " LIBPUPDMD_SHA: ${LIBPUPDMD_SHA}" +echo " NUM_PROCS: ${NUM_PROCS}" echo "" if [ -z "${BUILD_TYPE}" ]; then @@ -74,6 +75,7 @@ cmake \ -B build cmake --build build -- -j${NUM_PROCS} cp src/ZeDMD.h ../../third-party/include/ +cp third-party/include/FrameUtil.h ../../third-party/include/ cp build/libzedmd.so ../../third-party/runtime-libs/android/arm64-v8a/ cp -r test ../../ cd .. diff --git a/platforms/ios/arm64/external.sh b/platforms/ios/arm64/external.sh index 412fc65..b8df6ab 100755 --- a/platforms/ios/arm64/external.sh +++ b/platforms/ios/arm64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=42d95ed6f1fe2065ecbd247502d177d7e5eb7e4c +LIBZEDMD_SHA=340d0fbe0afbaf5583303599473bcc9ddc7bed0f LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c @@ -62,6 +62,7 @@ cmake \ -B build cmake --build build -- -j${NUM_PROCS} cp src/ZeDMD.h ../../third-party/include/ +cp third-party/include/FrameUtil.h ../../third-party/include/ cp build/libzedmd.a ../../third-party/build-libs/ios/arm64/ cp -r test ../../ cd .. diff --git a/platforms/linux/aarch64/external.sh b/platforms/linux/aarch64/external.sh index 5dbe20e..e959dd7 100755 --- a/platforms/linux/aarch64/external.sh +++ b/platforms/linux/aarch64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=42d95ed6f1fe2065ecbd247502d177d7e5eb7e4c +LIBZEDMD_SHA=340d0fbe0afbaf5583303599473bcc9ddc7bed0f LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c @@ -64,6 +64,7 @@ cmake \ cmake --build build -- -j${NUM_PROCS} cp src/ZeDMD.h ../../third-party/include/ cp third-party/include/libserialport.h ../../third-party/include/ +cp third-party/include/FrameUtil.h ../../third-party/include/ ln -s $(ls -v third-party/runtime-libs/linux/aarch64/libserialport.so.* | tail -n 1 | xargs basename) third-party/runtime-libs/linux/aarch64/libserialport.so cp -a third-party/runtime-libs/linux/aarch64/libserialport.{so,so.*} ../../third-party/runtime-libs/linux/aarch64/ cp -a build/libzedmd.{so,so.*} ../../third-party/runtime-libs/linux/aarch64/ diff --git a/platforms/linux/x64/external.sh b/platforms/linux/x64/external.sh index 71dcdbd..0ffa2f7 100755 --- a/platforms/linux/x64/external.sh +++ b/platforms/linux/x64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=42d95ed6f1fe2065ecbd247502d177d7e5eb7e4c +LIBZEDMD_SHA=340d0fbe0afbaf5583303599473bcc9ddc7bed0f LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c @@ -64,6 +64,7 @@ cmake \ cmake --build build -- -j${NUM_PROCS} cp src/ZeDMD.h ../../third-party/include/ cp third-party/include/libserialport.h ../../third-party/include/ +cp third-party/include/FrameUtil.h ../../third-party/include/ ln -s $(ls -v third-party/runtime-libs/linux/x64/libserialport.so.* | tail -n 1 | xargs basename) third-party/runtime-libs/linux/x64/libserialport.so cp -a third-party/runtime-libs/linux/x64/libserialport.{so,so.*} ../../third-party/runtime-libs/linux/x64/ cp -a build/libzedmd.{so,so.*} ../../third-party/runtime-libs/linux/x64/ diff --git a/platforms/macos/arm64/external.sh b/platforms/macos/arm64/external.sh index 4fb3bf7..71c8516 100755 --- a/platforms/macos/arm64/external.sh +++ b/platforms/macos/arm64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=42d95ed6f1fe2065ecbd247502d177d7e5eb7e4c +LIBZEDMD_SHA=340d0fbe0afbaf5583303599473bcc9ddc7bed0f LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c @@ -66,6 +66,7 @@ cmake \ cmake --build build -- -j${NUM_PROCS} cp src/ZeDMD.h ../../third-party/include/ cp third-party/include/libserialport.h ../../third-party/include/ +cp third-party/include/FrameUtil.h ../../third-party/include/ cp -a third-party/runtime-libs/macos/arm64/*.dylib ../../third-party/runtime-libs/macos/arm64/ cp -a build/*.dylib ../../third-party/runtime-libs/macos/arm64/ cp -r test ../../ diff --git a/platforms/macos/x64/external.sh b/platforms/macos/x64/external.sh index ec29cd3..903ad91 100755 --- a/platforms/macos/x64/external.sh +++ b/platforms/macos/x64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=42d95ed6f1fe2065ecbd247502d177d7e5eb7e4c +LIBZEDMD_SHA=340d0fbe0afbaf5583303599473bcc9ddc7bed0f LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c @@ -66,6 +66,7 @@ cmake \ cmake --build build -- -j${NUM_PROCS} cp src/ZeDMD.h ../../third-party/include/ cp third-party/include/libserialport.h ../../third-party/include/ +cp third-party/include/FrameUtil.h ../../third-party/include/ cp -a third-party/runtime-libs/macos/x64/*.dylib ../../third-party/runtime-libs/macos/x64/ cp -a build/*.dylib ../../third-party/runtime-libs/macos/x64/ cp -r test ../../ diff --git a/platforms/tvos/arm64/external.sh b/platforms/tvos/arm64/external.sh index 0ec573e..286f2f9 100755 --- a/platforms/tvos/arm64/external.sh +++ b/platforms/tvos/arm64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=42d95ed6f1fe2065ecbd247502d177d7e5eb7e4c +LIBZEDMD_SHA=340d0fbe0afbaf5583303599473bcc9ddc7bed0f LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c @@ -62,6 +62,7 @@ cmake \ -B build cmake --build build -- -j${NUM_PROCS} cp src/ZeDMD.h ../../third-party/include/ +cp third-party/include/FrameUtil.h ../../third-party/include/ cp build/libzedmd.a ../../third-party/build-libs/tvos/arm64/ cp -r test ../../ cd .. diff --git a/platforms/win/x64/external.sh b/platforms/win/x64/external.sh index 5999d61..aac4ff0 100755 --- a/platforms/win/x64/external.sh +++ b/platforms/win/x64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=42d95ed6f1fe2065ecbd247502d177d7e5eb7e4c +LIBZEDMD_SHA=340d0fbe0afbaf5583303599473bcc9ddc7bed0f LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c @@ -63,6 +63,7 @@ cmake \ cmake --build build --config ${BUILD_TYPE} cp src/ZeDMD.h ../../third-party/include/ cp third-party/include/libserialport.h ../../third-party/include/ +cp third-party/include/FrameUtil.h ../../third-party/include/ cp third-party/build-libs/win/x64/libserialport64.lib ../../third-party/build-libs/win/x64/ cp third-party/runtime-libs/win/x64/libserialport64.dll ../../third-party/runtime-libs/win/x64/ cp build/${BUILD_TYPE}/zedmd64.lib ../../third-party/build-libs/win/x64/ diff --git a/platforms/win/x86/external.sh b/platforms/win/x86/external.sh index 03e2797..8de795f 100755 --- a/platforms/win/x86/external.sh +++ b/platforms/win/x86/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=42d95ed6f1fe2065ecbd247502d177d7e5eb7e4c +LIBZEDMD_SHA=340d0fbe0afbaf5583303599473bcc9ddc7bed0f LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c @@ -64,6 +64,7 @@ cmake \ cmake --build build --config ${BUILD_TYPE} cp src/ZeDMD.h ../../third-party/include/ cp third-party/include/libserialport.h ../../third-party/include/ +cp third-party/include/FrameUtil.h ../../third-party/include/ cp third-party/build-libs/win/x86/libserialport.lib ../../third-party/build-libs/win/x86/ cp third-party/runtime-libs/win/x86/libserialport.dll ../../third-party/runtime-libs/win/x86/ cp build/${BUILD_TYPE}/zedmd.lib ../../third-party/build-libs/win/x86/ diff --git a/src/DMD.cpp b/src/DMD.cpp index a4f0266..8680612 100644 --- a/src/DMD.cpp +++ b/src/DMD.cpp @@ -770,11 +770,11 @@ void DMD::PixelcadeDMDThread() if (width == 128 && height == 32) memcpy(scaledBuffer, m_pUpdateBufferQueue[bufferPosition]->segData, 128 * 32 * 3); else if (width == 128 && height == 16) - FrameUtil::Center(scaledBuffer, 128, 32, rgb24Data, 128, 16, 24); + FrameUtil::Helper::Center(scaledBuffer, 128, 32, rgb24Data, 128, 16, 24); else if (width == 192 && height == 64) - FrameUtil::ScaleDown(scaledBuffer, 128, 32, rgb24Data, 192, 64, 24); + FrameUtil::Helper::ScaleDown(scaledBuffer, 128, 32, rgb24Data, 192, 64, 24); else if (width == 256 && height == 64) - FrameUtil::ScaleDown(scaledBuffer, 128, 32, rgb24Data, 256, 64, 24); + FrameUtil::Helper::ScaleDown(scaledBuffer, 128, 32, rgb24Data, 256, 64, 24); else continue; @@ -794,14 +794,14 @@ void DMD::PixelcadeDMDThread() if (width == 128 && height == 32) memcpy(rgb565Data, m_pUpdateBufferQueue[bufferPosition]->segData, 128 * 32 * 2); else if (width == 128 && height == 16) - FrameUtil::Center((uint8_t*)rgb565Data, 128, 32, (uint8_t*)m_pUpdateBufferQueue[bufferPosition]->segData, - 128, 16, 16); + FrameUtil::Helper::Center((uint8_t*)rgb565Data, 128, 32, + (uint8_t*)m_pUpdateBufferQueue[bufferPosition]->segData, 128, 16, 16); else if (width == 192 && height == 64) - FrameUtil::ScaleDown((uint8_t*)rgb565Data, 128, 32, (uint8_t*)m_pUpdateBufferQueue[bufferPosition]->segData, - 192, 64, 16); + FrameUtil::Helper::ScaleDown((uint8_t*)rgb565Data, 128, 32, + (uint8_t*)m_pUpdateBufferQueue[bufferPosition]->segData, 192, 64, 16); else if (width == 256 && height == 64) - FrameUtil::ScaleDown((uint8_t*)rgb565Data, 128, 32, (uint8_t*)m_pUpdateBufferQueue[bufferPosition]->segData, - 256, 64, 16); + FrameUtil::Helper::ScaleDown((uint8_t*)rgb565Data, 128, 32, + (uint8_t*)m_pUpdateBufferQueue[bufferPosition]->segData, 256, 64, 16); else continue; @@ -840,11 +840,11 @@ void DMD::PixelcadeDMDThread() if (width == 128 && height == 32) memcpy(scaledBuffer, renderBuffer, 128 * 32); else if (width == 128 && height == 16) - FrameUtil::CenterIndexed(scaledBuffer, 128, 32, renderBuffer, 128, 16); + FrameUtil::Helper::CenterIndexed(scaledBuffer, 128, 32, renderBuffer, 128, 16); else if (width == 192 && height == 64) - FrameUtil::ScaleDownIndexed(scaledBuffer, 128, 32, renderBuffer, 192, 64); + FrameUtil::Helper::ScaleDownIndexed(scaledBuffer, 128, 32, renderBuffer, 192, 64); else if (width == 256 && height == 64) - FrameUtil::ScaleDownIndexed(scaledBuffer, 128, 32, renderBuffer, 256, 64); + FrameUtil::Helper::ScaleDownIndexed(scaledBuffer, 128, 32, renderBuffer, 256, 64); else continue; @@ -1113,7 +1113,7 @@ bool DMD::UpdatePalette(uint8_t* pPalette, uint8_t depth, uint8_t r, uint8_t g, for (uint8_t i = 0; i < colors; i++) { - float perc = FrameUtil::CalcBrightness((float)i / (float)(colors - 1)); + float perc = FrameUtil::Helper::CalcBrightness((float)i / (float)(colors - 1)); pPalette[pos++] = (uint8_t)((float)r * perc); pPalette[pos++] = (uint8_t)((float)g * perc); pPalette[pos++] = (uint8_t)((float)b * perc); @@ -1393,9 +1393,9 @@ void DMD::PupDMDThread() if (width == 128 && height == 32) memcpy(scaledBuffer, renderBuffer, 128 * 32); else if (width == 128 && height == 16) - FrameUtil::CenterIndexed(scaledBuffer, 128, 32, renderBuffer, 128, 16); + FrameUtil::Helper::CenterIndexed(scaledBuffer, 128, 32, renderBuffer, 128, 16); else if (width == 192 && height == 64) - FrameUtil::ScaleDownPUP(scaledBuffer, 128, 32, renderBuffer, 192, 64); + FrameUtil::Helper::ScaleDownPUP(scaledBuffer, 128, 32, renderBuffer, 192, 64); else return; diff --git a/src/FrameUtil.cpp b/src/FrameUtil.cpp deleted file mode 100644 index 93e5f60..0000000 --- a/src/FrameUtil.cpp +++ /dev/null @@ -1,450 +0,0 @@ -/* - * Portions of this code was derived from DMDExt - * - * https://github.com/freezy/dmd-extensions/blob/master/LibDmd/Common/FrameUtil.cs - */ - -#include "FrameUtil.h" - -#include -#include -#include -#include - -namespace DMDUtil -{ - -inline int FrameUtil::MapAdafruitIndex(int x, int y, int width, int height, int numLogicalRows) -{ - int logicalRowLengthPerMatrix = 32 * 32 / 2 / numLogicalRows; - int logicalRow = y % numLogicalRows; - int dotPairsPerLogicalRow = width * height / numLogicalRows / 2; - int widthInMatrices = width / 32; - int matrixX = x / 32; - int matrixY = y / 32; - int totalMatrices = width * height / 1024; - int matrixNumber = totalMatrices - ((matrixY + 1) * widthInMatrices) + matrixX; - int indexWithinMatrixRow = x % logicalRowLengthPerMatrix; - int index = logicalRow * dotPairsPerLogicalRow + matrixNumber * logicalRowLengthPerMatrix + indexWithinMatrixRow; - return index; -} - -void FrameUtil::SplitIntoRgbPlanes(const uint16_t* rgb565, int rgb565Size, int width, int numLogicalRows, uint8_t* dest, - ColorMatrix colorMatrix) -{ - constexpr int pairOffset = 16; - int height = rgb565Size / width; - int subframeSize = rgb565Size / 2; - - for (int x = 0; x < width; ++x) - { - for (int y = 0; y < height; ++y) - { - if (y % (pairOffset * 2) >= pairOffset) continue; - - int inputIndex0 = y * width + x; - int inputIndex1 = inputIndex0 + pairOffset * width; - - uint16_t color0 = rgb565[inputIndex0]; - uint16_t color1 = rgb565[inputIndex1]; - - int r0 = 0, r1 = 0, g0 = 0, g1 = 0, b0 = 0, b1 = 0; - switch (colorMatrix) - { - case ColorMatrix::Rgb: - r0 = (color0 >> 13) /*& 0x7*/; - g0 = (color0 >> 8) /*& 0x7*/; - b0 = (color0 >> 2) /*& 0x7*/; - r1 = (color1 >> 13) /*& 0x7*/; - g1 = (color1 >> 8) /*& 0x7*/; - b1 = (color1 >> 2) /*& 0x7*/; - break; - - case ColorMatrix::Rbg: - r0 = (color0 >> 13) /*& 0x7*/; - b0 = (color0 >> 8) /*& 0x7*/; - g0 = (color0 >> 2) /*& 0x7*/; - r1 = (color1 >> 13) /*& 0x7*/; - b1 = (color1 >> 8) /*& 0x7*/; - g1 = (color1 >> 2) /*& 0x7*/; - break; - } - - for (int subframe = 0; subframe < 3; ++subframe) - { - uint8_t dotPair = (r0 & 1) << 5 | (g0 & 1) << 4 | (b0 & 1) << 3 | (r1 & 1) << 2 | (g1 & 1) << 1 | (b1 & 1); - int indexWithinSubframe = MapAdafruitIndex(x, y, width, height, numLogicalRows); - int indexWithinOutput = subframe * subframeSize + indexWithinSubframe; - dest[indexWithinOutput] = dotPair; - r0 >>= 1; - g0 >>= 1; - b0 >>= 1; - r1 >>= 1; - g1 >>= 1; - b1 >>= 1; - } - } - } -} - -inline uint16_t FrameUtil::InterpolateRgb565Color(uint16_t color1, uint16_t color2, float ratio) -{ - // ratio *= ratio*(3.0f-2.0f*ratio); // = biquintic - - int red1 = (int)color1 >> 11; - int green1 = ((int)color1 >> 5) & 0x3F; - int blue1 = (int)color1 & 0x1F; - - int red2 = (int)color2 >> 11; - int green2 = ((int)color2 >> 5) & 0x3F; - int blue2 = (int)color2 & 0x1F; - - int red = red1 + static_cast((float)(red2 - red1) * ratio); - int green = green1 + static_cast((float)(green2 - green1) * ratio); - int blue = blue1 + static_cast((float)(blue2 - blue1) * ratio); - - red = std::min(std::max(red, 0), 0x1F); - green = std::min(std::max(green, 0), 0x3F); - blue = std::min(std::max(blue, 0), 0x1F); - - return (uint16_t)((red << 11) | (green << 5) | blue); -} - -inline uint16_t FrameUtil::InterpolatedRgb565Pixel(const uint16_t* src, float srcX, float srcY, int srcWidth, - int srcHeight) -{ - int x = (int)srcX; - int y = (int)srcY; - float xDiff = srcX - (float)x; - float yDiff = srcY - (float)y; - - // xDiff *= xDiff*(3.0f-2.0f*xDiff); // = biquintic - // yDiff *= yDiff*(3.0f-2.0f*yDiff); - - const int offs = y * srcWidth + x; - int a = src[offs]; - int b = (x < srcWidth - 1) ? src[offs + 1] : a; - int c = (y < srcHeight - 1) ? src[offs + srcWidth] : a; - int d = (x < srcWidth - 1 && y < srcHeight - 1) ? src[offs + srcWidth + 1] : c; - - int red1 = a >> 11; - int green1 = (a >> 5) & 0x3F; - int blue1 = a & 0x1F; - - int red2 = b >> 11; - int green2 = (b >> 5) & 0x3F; - int blue2 = b & 0x1F; - - float redab = (float)red1 + (float)(red2 - red1) * xDiff; - float greenab = (float)green1 + (float)(green2 - green1) * xDiff; - float blueab = (float)blue1 + (float)(blue2 - blue1) * xDiff; - - red1 = c >> 11; - green1 = (c >> 5) & 0x3F; - blue1 = c & 0x1F; - - red2 = d >> 11; - green2 = (d >> 5) & 0x3F; - blue2 = d & 0x1F; - - float redcd = (float)red1 + (float)(red2 - red1) * xDiff; - float greencd = (float)green1 + (float)(green2 - green1) * xDiff; - float bluecd = (float)blue1 + (float)(blue2 - blue1) * xDiff; - - float red = redab + (redcd - redab) * yDiff; - float green = greenab + (greencd - greenab) * yDiff; - float blue = blueab + (bluecd - blueab) * yDiff; - - red = std::min(std::max(red, 0.f), (float)0x1F); - green = std::min(std::max(green, 0.f), (float)0x3F); - blue = std::min(std::max(blue, 0.f), (float)0x1F); - - return (uint16_t)(((int)red << 11) | ((int)green << 5) | (int)blue); -} - -void FrameUtil::ResizeRgb565Bilinear(const uint16_t* src, int srcWidth, int srcHeight, uint16_t* dest, int destWidth, - int destHeight) -{ - memset(dest, 0, destWidth * destHeight * sizeof(uint16_t)); - - float srcAspect = (float)srcWidth / (float)srcHeight; - float destAspect = (float)destWidth / (float)destHeight; - int scaledWidth, scaledHeight; - - if (srcAspect > destAspect) - { - scaledWidth = destWidth; - scaledHeight = (int)((float)destWidth / srcAspect); - } - else - { - scaledHeight = destHeight; - scaledWidth = (int)((float)destHeight * srcAspect); - } - - int offsetX = (destWidth - scaledWidth) / 2; - int offsetY = (destHeight - scaledHeight) / 2; - int offs = offsetX + offsetY * destWidth; - - for (int y = 0; y < scaledHeight; ++y) - { - for (int x = 0; x < scaledWidth; ++x) - { - float srcX = ((float)x + 0.5f) * ((float)srcWidth / (float)scaledWidth) - 0.5f; - float srcY = ((float)y + 0.5f) * ((float)srcHeight / (float)scaledHeight) - 0.5f; - - srcX = std::max(0.0f, std::min(srcX, static_cast(srcWidth - 1))); - srcY = std::max(0.0f, std::min(srcY, static_cast(srcHeight - 1))); - - dest[y * destWidth + offs + x] = InterpolatedRgb565Pixel(src, srcX, srcY, srcWidth, srcHeight); - } - } -} - -float FrameUtil::CalcBrightness(float x) -{ - // function to improve the brightness with fx=ax²+bc+c, f(0)=0, f(1)=1, f'(1.1)=0 - return (-x * x + 2.1f * x) / 1.1f; -} - -std::string FrameUtil::HexDump(const uint8_t* data, size_t size) -{ - constexpr int bytesPerLine = 32; - - std::stringstream ss; - - for (size_t i = 0; i < size; i += bytesPerLine) - { - for (size_t j = i; j < i + bytesPerLine && j < size; ++j) - ss << std::setw(2) << std::setfill('0') << std::hex << static_cast(data[j]) << ' '; - - for (size_t j = i; j < i + bytesPerLine && j < size; ++j) - { - char ch = data[j]; - if (ch < 32 || ch > 126) ch = '.'; - ss << ch; - } - - ss << std::endl; - } - - return ss.str(); -} - -void FrameUtil::ScaleDownIndexed(uint8_t* pDestFrame, const uint8_t destWidth, const uint8_t destHeight, - const uint8_t* pSrcFrame, const uint16_t srcWidth, const uint8_t srcHeight) -{ - memset(pDestFrame, 0, destWidth * destHeight); - uint8_t xOffset = (destWidth - (srcWidth / 2)) / 2; - uint8_t yOffset = (destHeight - (srcHeight / 2)) / 2; - - // for half scaling we take the 4 points and look if there is one color repeated - for (uint8_t y = 0; y < srcHeight; y += 2) - { - std::vector row; - row.reserve(srcWidth / 2); - - for (uint16_t x = 0; x < srcWidth; x += 2) - { - uint8_t upper_left = pSrcFrame[y * srcWidth + x]; - uint8_t upper_right = pSrcFrame[y * srcWidth + x + 1]; - uint8_t lower_left = pSrcFrame[(y + 1) * srcWidth + x]; - uint8_t lower_right = pSrcFrame[(y + 1) * srcWidth + x + 1]; - - if (x < srcWidth / 2) - { - if (y < srcHeight / 2) - { - if (upper_left == upper_right || upper_left == lower_left || upper_left == lower_right) - row.push_back(upper_left); - else if (upper_right == lower_left || upper_right == lower_right) - row.push_back(upper_right); - else if (lower_left == lower_right) - row.push_back(lower_left); - else - row.push_back(upper_left); - } - else - { - if (lower_left == lower_right || lower_left == upper_left || lower_left == upper_right) - row.push_back(lower_right); - else if (lower_right == upper_left || lower_right == upper_right) - row.push_back(lower_right); - else if (upper_left == upper_right) - row.push_back(upper_left); - else - row.push_back(lower_left); - } - } - else - { - if (y < srcHeight / 2) - { - if (upper_right == upper_left || upper_right == lower_right || upper_right == lower_left) - row.push_back(upper_right); - else if (upper_left == lower_right || upper_left == lower_left) - row.push_back(upper_left); - else if (lower_right == lower_left) - row.push_back(lower_right); - else - row.push_back(upper_right); - } - else - { - if (lower_right == lower_left || lower_right == upper_right || lower_right == upper_left) - row.push_back(lower_right); - else if (lower_left == upper_right || lower_left == upper_left) - row.push_back(lower_left); - else if (upper_right == upper_left) - row.push_back(upper_right); - else - row.push_back(lower_right); - } - } - } - - memcpy(&pDestFrame[(yOffset + (y / 2)) * destWidth + xOffset], row.data(), srcWidth / 2); - } -} - -void FrameUtil::ScaleDownPUP(uint8_t* pDestFrame, const uint8_t destWidth, const uint8_t destHeight, - const uint8_t* pSrcFrame, const uint8_t srcWidth, const uint8_t srcHeight) -{ - memset(pDestFrame, 0, destWidth * destHeight); - uint8_t xOffset = (destWidth - (srcWidth / 2)) / 2; - uint8_t yOffset = (destHeight - (srcHeight / 2)) / 2; - - // for half scaling we take the 4 points and look if there is one color repeated - for (uint8_t y = 0; y < srcHeight; y += 2) - { - std::vector row; - row.reserve(srcWidth / 2); - - for (uint8_t x = 0; x < srcWidth; x += 2) - { - uint8_t pixel1 = pSrcFrame[y * srcWidth + x]; - uint8_t pixel2 = pSrcFrame[y * srcWidth + x + 1]; - uint8_t pixel3 = pSrcFrame[(y + 1) * srcWidth + x]; - uint8_t pixel4 = pSrcFrame[(y + 1) * srcWidth + x + 1]; - - if (pixel1 == pixel2 || pixel1 == pixel3 || pixel1 == pixel4) - row.push_back(pixel1); - else if (pixel2 == pixel3 || pixel2 == pixel4) - row.push_back(pixel2); - else if (pixel3 == pixel4) - row.push_back(pixel3); - else - row.push_back(pixel1); - } - - memcpy(&pDestFrame[(yOffset + (y / 2)) * destWidth + xOffset], row.data(), srcWidth / 2); - } -} - -void FrameUtil::ScaleDown(uint8_t* pDestFrame, const uint8_t destWidth, const uint8_t destHeight, - const uint8_t* pSrcFrame, const uint16_t srcWidth, const uint8_t srcHeight, uint8_t bits) -{ - memset(pDestFrame, 0, destWidth * destHeight); - uint8_t xOffset = (destWidth - (srcWidth / 2)) / 2; - uint8_t yOffset = (destHeight - (srcHeight / 2)) / 2; - uint8_t bytes = bits / 8; // RGB24 (3 byte) or RGB16 (2 byte) - - for (uint8_t y = 0; y < srcHeight; y += 2) - { - for (uint16_t x = 0; x < srcWidth; x += 2) - { - uint16_t upper_left = y * srcWidth * bytes + x * bytes; - uint16_t upper_right = upper_left + bytes; - uint16_t lower_left = upper_left + srcWidth * bytes; - uint16_t lower_right = lower_left + bytes; - uint16_t target = (xOffset + (x / 2) + (y / 2) * destHeight) * bytes; - - if (x < srcWidth / 2) - { - if (y < srcHeight / 2) - { - if (memcmp(&pSrcFrame[upper_left], &pSrcFrame[upper_right], bytes) == 0 || - memcmp(&pSrcFrame[upper_left], &pSrcFrame[lower_left], bytes) == 0 || - memcmp(&pSrcFrame[upper_left], &pSrcFrame[lower_right], bytes) == 0) - memcpy(&pDestFrame[target], &pSrcFrame[upper_left], bytes); - else if (memcmp(&pSrcFrame[upper_right], &pSrcFrame[lower_left], bytes) == 0 || - memcmp(&pSrcFrame[upper_right], &pSrcFrame[lower_right], bytes) == 0) - memcpy(&pDestFrame[target], &pSrcFrame[upper_right], bytes); - else if (memcmp(&pSrcFrame[lower_left], &pSrcFrame[lower_right], bytes) == 0) - memcpy(&pDestFrame[target], &pSrcFrame[lower_left], bytes); - else - memcpy(&pDestFrame[target], &pSrcFrame[upper_left], bytes); - } - else - { - if (memcmp(&pSrcFrame[lower_left], &pSrcFrame[lower_right], bytes) == 0 || - memcmp(&pSrcFrame[lower_left], &pSrcFrame[upper_left], bytes) == 0 || - memcmp(&pSrcFrame[lower_left], &pSrcFrame[upper_right], bytes) == 0) - memcpy(&pDestFrame[target], &pSrcFrame[lower_left], bytes); - else if (memcmp(&pSrcFrame[lower_right], &pSrcFrame[upper_left], bytes) == 0 || - memcmp(&pSrcFrame[lower_right], &pSrcFrame[upper_right], bytes) == 0) - memcpy(&pDestFrame[target], &pSrcFrame[lower_right], bytes); - else if (memcmp(&pSrcFrame[upper_left], &pSrcFrame[upper_right], bytes) == 0) - memcpy(&pDestFrame[target], &pSrcFrame[upper_left], bytes); - else - memcpy(&pDestFrame[target], &pSrcFrame[lower_left], bytes); - } - } - else - { - if (y < srcHeight / 2) - { - if (memcmp(&pSrcFrame[upper_right], &pSrcFrame[upper_left], bytes) == 0 || - memcmp(&pSrcFrame[upper_right], &pSrcFrame[lower_right], bytes) == 0 || - memcmp(&pSrcFrame[upper_right], &pSrcFrame[lower_left], bytes) == 0) - memcpy(&pDestFrame[target], &pSrcFrame[upper_right], bytes); - else if (memcmp(&pSrcFrame[upper_left], &pSrcFrame[lower_right], bytes) == 0 || - memcmp(&pSrcFrame[upper_left], &pSrcFrame[lower_left], bytes) == 0) - memcpy(&pDestFrame[target], &pSrcFrame[upper_left], bytes); - else if (memcmp(&pSrcFrame[lower_right], &pSrcFrame[lower_left], bytes) == 0) - memcpy(&pDestFrame[target], &pSrcFrame[lower_right], bytes); - else - memcpy(&pDestFrame[target], &pSrcFrame[upper_right], bytes); - } - else - { - if (memcmp(&pSrcFrame[lower_right], &pSrcFrame[lower_left], bytes) == 0 || - memcmp(&pSrcFrame[lower_right], &pSrcFrame[upper_right], bytes) == 0 || - memcmp(&pSrcFrame[lower_right], &pSrcFrame[upper_left], bytes) == 0) - memcpy(&pDestFrame[target], &pSrcFrame[lower_right], bytes); - else if (memcmp(&pSrcFrame[lower_left], &pSrcFrame[upper_right], bytes) == 0 || - memcmp(&pSrcFrame[lower_left], &pSrcFrame[upper_left], bytes) == 0) - memcpy(&pDestFrame[target], &pSrcFrame[lower_left], bytes); - else if (memcmp(&pSrcFrame[upper_right], &pSrcFrame[upper_left], bytes) == 0) - memcpy(&pDestFrame[target], &pSrcFrame[upper_right], bytes); - else - memcpy(&pDestFrame[target], &pSrcFrame[lower_right], bytes); - } - } - } - } -} - -void FrameUtil::Center(uint8_t* pDestFrame, const uint8_t destWidth, const uint8_t destHeight, const uint8_t* pSrcFrame, - const uint8_t srcWidth, const uint8_t srcHeight, uint8_t bits) -{ - uint8_t bytes = bits / 8; // RGB24 (3 byte) or RGB16 (2 byte) - - memset(pDestFrame, 0, destWidth * destHeight * bytes); - uint8_t xOffset = (destWidth - srcWidth) / 2; - uint8_t yOffset = (destHeight - srcHeight) / 2; - - for (uint8_t y = 0; y < srcHeight; y++) - { - memcpy(&pDestFrame[((yOffset + y) * destWidth + xOffset) * bytes], &pSrcFrame[y * srcWidth * bytes], - srcWidth * bytes); - } -} - -void FrameUtil::CenterIndexed(uint8_t* pDestFrame, const uint8_t destWidth, const uint8_t destHeight, - const uint8_t* pSrcFrame, const uint8_t srcWidth, const uint8_t srcHeight) -{ - Center(pDestFrame, destWidth, destHeight, pSrcFrame, srcWidth, srcHeight, 8); -} - -} // namespace DMDUtil diff --git a/src/FrameUtil.h b/src/FrameUtil.h deleted file mode 100644 index 3787a88..0000000 --- a/src/FrameUtil.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Portions of this code was derived from DMDExt - * - * https://github.com/freezy/dmd-extensions/blob/master/LibDmd/Common/FrameUtil.cs - */ - -#pragma once - -#include -#include - -namespace DMDUtil -{ - -enum class ColorMatrix -{ - Rgb, - Rbg -}; - -class FrameUtil -{ - public: - static inline int MapAdafruitIndex(int x, int y, int width, int height, int numLogicalRows); - static void SplitIntoRgbPlanes(const uint16_t* rgb565, int rgb565Size, int width, int numLogicalRows, uint8_t* dest, - ColorMatrix colorMatrix = ColorMatrix::Rgb); - static inline uint16_t InterpolateRgb565Color(uint16_t color1, uint16_t color2, float ratio); - static inline uint16_t InterpolatedRgb565Pixel(const uint16_t* src, float srcX, float srcY, int srcWidth, - int srcHeight); - static void ResizeRgb565Bilinear(const uint16_t* src, int srcWidth, int srcHeight, uint16_t* dest, int destWidth, - int destHeight); - static float CalcBrightness(float x); - static std::string HexDump(const uint8_t* data, size_t size); - static void ScaleDownIndexed(uint8_t* pDestFrame, const uint8_t destWidth, const uint8_t destHeight, - const uint8_t* pSrcFrame, const uint16_t srcWidth, const uint8_t srcHeight); - static void ScaleDownPUP(uint8_t* pDestFrame, const uint8_t destWidth, const uint8_t destHeight, - const uint8_t* pSrcFrame, const uint8_t srcWidth, const uint8_t srcHeight); - static void ScaleDown(uint8_t* pDestFrame, const uint8_t destWidth, const uint8_t destHeight, - const uint8_t* pSrcFrame, const uint16_t srcWidth, const uint8_t srcHeight, uint8_t bits); - static void CenterIndexed(uint8_t* pDestFrame, const uint8_t destWidth, const uint8_t destHeight, - const uint8_t* pSrcFrame, const uint8_t srcWidth, const uint8_t srcHeight); - static void Center(uint8_t* pDestFrame, const uint8_t destWidth, const uint8_t destHeight, const uint8_t* pSrcFrame, - const uint8_t srcWidth, const uint8_t srcHeight, uint8_t bits); -}; - -} // namespace DMDUtil diff --git a/src/PixelcadeDMD.cpp b/src/PixelcadeDMD.cpp index 6be07e0..f4258b1 100644 --- a/src/PixelcadeDMD.cpp +++ b/src/PixelcadeDMD.cpp @@ -175,7 +175,8 @@ void PixelcadeDMD::Run() EnableRgbLedMatrix(4, 16); int errors = 0; - ColorMatrix colorMatrix = (m_matrix == 0) ? ColorMatrix::Rgb : ColorMatrix::Rbg; + FrameUtil::ColorMatrix colorMatrix = + (m_matrix == 0) ? FrameUtil::ColorMatrix::Rgb : FrameUtil::ColorMatrix::Rbg; while (m_running) { @@ -199,14 +200,7 @@ void PixelcadeDMD::Run() if (pFrame) { uint8_t planes[128 * 32 * 3 / 2]; - if (m_width == 128 && m_height == 32) - FrameUtil::SplitIntoRgbPlanes(pFrame, 128 * 32, 128, 16, (uint8_t*)planes, colorMatrix); - else - { - uint16_t scaledFrame[128 * 32]; - FrameUtil::ResizeRgb565Bilinear(pFrame, m_width, m_height, scaledFrame, 128, 32); - FrameUtil::SplitIntoRgbPlanes(scaledFrame, 128 * 32, 128, 16, (uint8_t*)planes, colorMatrix); - } + FrameUtil::Helper::SplitIntoRgbPlanes(pFrame, 128 * 32, 128, 16, (uint8_t*)planes, colorMatrix); static uint8_t command = PIXELCADE_COMMAND_RGB_LED_MATRIX_FRAME; sp_blocking_write(m_pSerialPort, &command, 1, PIXELCADE_COMMAND_WRITE_TIMEOUT); From c267522ac06506c9dc811918ba7a8f6ac2335247 Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Tue, 2 Apr 2024 21:17:39 +0200 Subject: [PATCH 2/6] libframeutil update --- platforms/android/arm64-v8a/external.sh | 2 +- platforms/ios/arm64/external.sh | 2 +- platforms/linux/aarch64/external.sh | 2 +- platforms/linux/x64/external.sh | 2 +- platforms/macos/arm64/external.sh | 2 +- platforms/macos/x64/external.sh | 2 +- platforms/tvos/arm64/external.sh | 2 +- platforms/win/x64/external.sh | 2 +- platforms/win/x86/external.sh | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/platforms/android/arm64-v8a/external.sh b/platforms/android/arm64-v8a/external.sh index 75911f3..ae50000 100755 --- a/platforms/android/arm64-v8a/external.sh +++ b/platforms/android/arm64-v8a/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=340d0fbe0afbaf5583303599473bcc9ddc7bed0f +LIBZEDMD_SHA=423325831c96a445ecc159ff4aca1421682613d5 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c diff --git a/platforms/ios/arm64/external.sh b/platforms/ios/arm64/external.sh index b8df6ab..2c9a2aa 100755 --- a/platforms/ios/arm64/external.sh +++ b/platforms/ios/arm64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=340d0fbe0afbaf5583303599473bcc9ddc7bed0f +LIBZEDMD_SHA=423325831c96a445ecc159ff4aca1421682613d5 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c diff --git a/platforms/linux/aarch64/external.sh b/platforms/linux/aarch64/external.sh index e959dd7..2e10eb4 100755 --- a/platforms/linux/aarch64/external.sh +++ b/platforms/linux/aarch64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=340d0fbe0afbaf5583303599473bcc9ddc7bed0f +LIBZEDMD_SHA=423325831c96a445ecc159ff4aca1421682613d5 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c diff --git a/platforms/linux/x64/external.sh b/platforms/linux/x64/external.sh index 0ffa2f7..b713f68 100755 --- a/platforms/linux/x64/external.sh +++ b/platforms/linux/x64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=340d0fbe0afbaf5583303599473bcc9ddc7bed0f +LIBZEDMD_SHA=423325831c96a445ecc159ff4aca1421682613d5 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c diff --git a/platforms/macos/arm64/external.sh b/platforms/macos/arm64/external.sh index 71c8516..0959d0b 100755 --- a/platforms/macos/arm64/external.sh +++ b/platforms/macos/arm64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=340d0fbe0afbaf5583303599473bcc9ddc7bed0f +LIBZEDMD_SHA=423325831c96a445ecc159ff4aca1421682613d5 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c diff --git a/platforms/macos/x64/external.sh b/platforms/macos/x64/external.sh index 903ad91..11c50b2 100755 --- a/platforms/macos/x64/external.sh +++ b/platforms/macos/x64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=340d0fbe0afbaf5583303599473bcc9ddc7bed0f +LIBZEDMD_SHA=423325831c96a445ecc159ff4aca1421682613d5 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c diff --git a/platforms/tvos/arm64/external.sh b/platforms/tvos/arm64/external.sh index 286f2f9..24be68f 100755 --- a/platforms/tvos/arm64/external.sh +++ b/platforms/tvos/arm64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=340d0fbe0afbaf5583303599473bcc9ddc7bed0f +LIBZEDMD_SHA=423325831c96a445ecc159ff4aca1421682613d5 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c diff --git a/platforms/win/x64/external.sh b/platforms/win/x64/external.sh index aac4ff0..d2038d5 100755 --- a/platforms/win/x64/external.sh +++ b/platforms/win/x64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=340d0fbe0afbaf5583303599473bcc9ddc7bed0f +LIBZEDMD_SHA=423325831c96a445ecc159ff4aca1421682613d5 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c diff --git a/platforms/win/x86/external.sh b/platforms/win/x86/external.sh index 8de795f..506b7c3 100755 --- a/platforms/win/x86/external.sh +++ b/platforms/win/x86/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=340d0fbe0afbaf5583303599473bcc9ddc7bed0f +LIBZEDMD_SHA=423325831c96a445ecc159ff4aca1421682613d5 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c From a010a135e531c8b5b7e16c046cb13e15726dc1b3 Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Tue, 2 Apr 2024 23:56:19 +0200 Subject: [PATCH 3/6] ilibframeutil 0.2.0 --- platforms/android/arm64-v8a/external.sh | 2 +- platforms/ios/arm64/external.sh | 2 +- platforms/linux/aarch64/external.sh | 2 +- platforms/linux/x64/external.sh | 2 +- platforms/macos/arm64/external.sh | 2 +- platforms/macos/x64/external.sh | 2 +- platforms/tvos/arm64/external.sh | 2 +- platforms/win/x64/external.sh | 2 +- platforms/win/x86/external.sh | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/platforms/android/arm64-v8a/external.sh b/platforms/android/arm64-v8a/external.sh index ae50000..27ea2ce 100755 --- a/platforms/android/arm64-v8a/external.sh +++ b/platforms/android/arm64-v8a/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=423325831c96a445ecc159ff4aca1421682613d5 +LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c diff --git a/platforms/ios/arm64/external.sh b/platforms/ios/arm64/external.sh index 2c9a2aa..beb94a7 100755 --- a/platforms/ios/arm64/external.sh +++ b/platforms/ios/arm64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=423325831c96a445ecc159ff4aca1421682613d5 +LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c diff --git a/platforms/linux/aarch64/external.sh b/platforms/linux/aarch64/external.sh index 2e10eb4..56c6991 100755 --- a/platforms/linux/aarch64/external.sh +++ b/platforms/linux/aarch64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=423325831c96a445ecc159ff4aca1421682613d5 +LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c diff --git a/platforms/linux/x64/external.sh b/platforms/linux/x64/external.sh index b713f68..f36bd6f 100755 --- a/platforms/linux/x64/external.sh +++ b/platforms/linux/x64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=423325831c96a445ecc159ff4aca1421682613d5 +LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c diff --git a/platforms/macos/arm64/external.sh b/platforms/macos/arm64/external.sh index 0959d0b..dddf625 100755 --- a/platforms/macos/arm64/external.sh +++ b/platforms/macos/arm64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=423325831c96a445ecc159ff4aca1421682613d5 +LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c diff --git a/platforms/macos/x64/external.sh b/platforms/macos/x64/external.sh index 11c50b2..8fabd82 100755 --- a/platforms/macos/x64/external.sh +++ b/platforms/macos/x64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=423325831c96a445ecc159ff4aca1421682613d5 +LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c diff --git a/platforms/tvos/arm64/external.sh b/platforms/tvos/arm64/external.sh index 24be68f..435f101 100755 --- a/platforms/tvos/arm64/external.sh +++ b/platforms/tvos/arm64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=423325831c96a445ecc159ff4aca1421682613d5 +LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c diff --git a/platforms/win/x64/external.sh b/platforms/win/x64/external.sh index d2038d5..da14fa3 100755 --- a/platforms/win/x64/external.sh +++ b/platforms/win/x64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=423325831c96a445ecc159ff4aca1421682613d5 +LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c diff --git a/platforms/win/x86/external.sh b/platforms/win/x86/external.sh index 506b7c3..44e9493 100755 --- a/platforms/win/x86/external.sh +++ b/platforms/win/x86/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=423325831c96a445ecc159ff4aca1421682613d5 +LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c From ba77dccf70bb05f609a6583d169f8b06fc94254f Mon Sep 17 00:00:00 2001 From: Jason Millard Date: Wed, 3 Apr 2024 07:19:50 -0400 Subject: [PATCH 4/6] misc: move Frameutil.h into third-party for portability --- platforms/android/arm64-v8a/external.sh | 1 - platforms/ios/arm64/external.sh | 1 - platforms/macos/arm64/external.sh | 1 - platforms/macos/x64/external.sh | 1 - platforms/tvos/arm64/external.sh | 1 - platforms/win/x64/external.sh | 1 - platforms/win/x86/external.sh | 1 - third-party/README.md | 9 + third-party/include/FrameUtil.h | 541 ++++++++++++++++++++++++ 9 files changed, 550 insertions(+), 7 deletions(-) create mode 100644 third-party/include/FrameUtil.h diff --git a/platforms/android/arm64-v8a/external.sh b/platforms/android/arm64-v8a/external.sh index 27ea2ce..7e64cd9 100755 --- a/platforms/android/arm64-v8a/external.sh +++ b/platforms/android/arm64-v8a/external.sh @@ -75,7 +75,6 @@ cmake \ -B build cmake --build build -- -j${NUM_PROCS} cp src/ZeDMD.h ../../third-party/include/ -cp third-party/include/FrameUtil.h ../../third-party/include/ cp build/libzedmd.so ../../third-party/runtime-libs/android/arm64-v8a/ cp -r test ../../ cd .. diff --git a/platforms/ios/arm64/external.sh b/platforms/ios/arm64/external.sh index beb94a7..62ff27f 100755 --- a/platforms/ios/arm64/external.sh +++ b/platforms/ios/arm64/external.sh @@ -62,7 +62,6 @@ cmake \ -B build cmake --build build -- -j${NUM_PROCS} cp src/ZeDMD.h ../../third-party/include/ -cp third-party/include/FrameUtil.h ../../third-party/include/ cp build/libzedmd.a ../../third-party/build-libs/ios/arm64/ cp -r test ../../ cd .. diff --git a/platforms/macos/arm64/external.sh b/platforms/macos/arm64/external.sh index dddf625..367af95 100755 --- a/platforms/macos/arm64/external.sh +++ b/platforms/macos/arm64/external.sh @@ -66,7 +66,6 @@ cmake \ cmake --build build -- -j${NUM_PROCS} cp src/ZeDMD.h ../../third-party/include/ cp third-party/include/libserialport.h ../../third-party/include/ -cp third-party/include/FrameUtil.h ../../third-party/include/ cp -a third-party/runtime-libs/macos/arm64/*.dylib ../../third-party/runtime-libs/macos/arm64/ cp -a build/*.dylib ../../third-party/runtime-libs/macos/arm64/ cp -r test ../../ diff --git a/platforms/macos/x64/external.sh b/platforms/macos/x64/external.sh index 8fabd82..4673e61 100755 --- a/platforms/macos/x64/external.sh +++ b/platforms/macos/x64/external.sh @@ -66,7 +66,6 @@ cmake \ cmake --build build -- -j${NUM_PROCS} cp src/ZeDMD.h ../../third-party/include/ cp third-party/include/libserialport.h ../../third-party/include/ -cp third-party/include/FrameUtil.h ../../third-party/include/ cp -a third-party/runtime-libs/macos/x64/*.dylib ../../third-party/runtime-libs/macos/x64/ cp -a build/*.dylib ../../third-party/runtime-libs/macos/x64/ cp -r test ../../ diff --git a/platforms/tvos/arm64/external.sh b/platforms/tvos/arm64/external.sh index 435f101..b7933be 100755 --- a/platforms/tvos/arm64/external.sh +++ b/platforms/tvos/arm64/external.sh @@ -62,7 +62,6 @@ cmake \ -B build cmake --build build -- -j${NUM_PROCS} cp src/ZeDMD.h ../../third-party/include/ -cp third-party/include/FrameUtil.h ../../third-party/include/ cp build/libzedmd.a ../../third-party/build-libs/tvos/arm64/ cp -r test ../../ cd .. diff --git a/platforms/win/x64/external.sh b/platforms/win/x64/external.sh index da14fa3..8fef3b1 100755 --- a/platforms/win/x64/external.sh +++ b/platforms/win/x64/external.sh @@ -63,7 +63,6 @@ cmake \ cmake --build build --config ${BUILD_TYPE} cp src/ZeDMD.h ../../third-party/include/ cp third-party/include/libserialport.h ../../third-party/include/ -cp third-party/include/FrameUtil.h ../../third-party/include/ cp third-party/build-libs/win/x64/libserialport64.lib ../../third-party/build-libs/win/x64/ cp third-party/runtime-libs/win/x64/libserialport64.dll ../../third-party/runtime-libs/win/x64/ cp build/${BUILD_TYPE}/zedmd64.lib ../../third-party/build-libs/win/x64/ diff --git a/platforms/win/x86/external.sh b/platforms/win/x86/external.sh index 44e9493..774ad8b 100755 --- a/platforms/win/x86/external.sh +++ b/platforms/win/x86/external.sh @@ -64,7 +64,6 @@ cmake \ cmake --build build --config ${BUILD_TYPE} cp src/ZeDMD.h ../../third-party/include/ cp third-party/include/libserialport.h ../../third-party/include/ -cp third-party/include/FrameUtil.h ../../third-party/include/ cp third-party/build-libs/win/x86/libserialport.lib ../../third-party/build-libs/win/x86/ cp third-party/runtime-libs/win/x86/libserialport.dll ../../third-party/runtime-libs/win/x86/ cp build/${BUILD_TYPE}/zedmd.lib ../../third-party/build-libs/win/x86/ diff --git a/third-party/README.md b/third-party/README.md index 2f17db4..564b94b 100644 --- a/third-party/README.md +++ b/third-party/README.md @@ -26,3 +26,12 @@ - Upstream: https://github.com/zesinger/libserum - License: GPL-2.0 license +## libpupdmd + +- Upstream: https://github.com/ppuc/libpupdmd +- License: GPL-3.0 license + +## libframeutil + +- Upstream: https://github.com/PPUC/libframeutil +- License: GPL-3.0 license \ No newline at end of file diff --git a/third-party/include/FrameUtil.h b/third-party/include/FrameUtil.h new file mode 100644 index 0000000..c8db798 --- /dev/null +++ b/third-party/include/FrameUtil.h @@ -0,0 +1,541 @@ +/* + * Portions of this code was derived from DMDExt: + * https://github.com/freezy/dmd-extensions/blob/master/LibDmd/Common/FrameUtil.cs + * + * Some were extracted from libzedmd: + * https://github.com/PPUC/libzedmd + */ + +#pragma once + +#define FRAMEUTIL_VERSION_MAJOR 0 // X Digits +#define FRAMEUTIL_VERSION_MINOR 2 // Max 2 Digits +#define FRAMEUTIL_VERSION_PATCH 0 // Max 2 Digits + +#define _FRAMEUTIL_STR(x) #x +#define FRAMEUTIL_STR(x) _FRAMEUTIL_STR(x) + +#define FRAMEUTIL_VERSION \ + FRAMEUTIL_STR(FRAMEUTIL_VERSION_MAJOR) \ + "." FRAMEUTIL_STR(FRAMEUTIL_VERSION_MINOR) "." FRAMEUTIL_STR(FRAMEUTIL_VERSION_PATCH) +#define FRAMEUTIL_MINOR_VERSION FRAMEUTIL_STR(FRAMEUTIL_VERSION_MAJOR) "." FRAMEUTIL_STR(FRAMEUTIL_VERSION_MINOR) + +#include +#include +#include +#include +#include +#include + +namespace FrameUtil +{ + +enum class ColorMatrix +{ + Rgb, + Rbg +}; + +class Helper +{ + public: + static int MapAdafruitIndex(int x, int y, int width, int height, int numLogicalRows); + static void ConvertToRgb24(uint8_t* pFrameRgb24, uint8_t* pFrame, int size, uint8_t* pPalette); + static void Split(uint8_t* pPlanes, uint16_t width, uint16_t height, uint8_t bitlen, uint8_t* pFrame); + static void SplitIntoRgbPlanes(const uint16_t* rgb565, int rgb565Size, int width, int numLogicalRows, uint8_t* dest, + ColorMatrix colorMatrix = ColorMatrix::Rgb); + static float CalcBrightness(float x); + static void ScaleDownIndexed(uint8_t* pDestFrame, const uint16_t destWidth, const uint8_t destHeight, + const uint8_t* pSrcFrame, const uint16_t srcWidth, const uint8_t srcHeight); + static void ScaleDownPUP(uint8_t* pDestFrame, const uint16_t destWidth, const uint8_t destHeight, + const uint8_t* pSrcFrame, const uint16_t srcWidth, const uint8_t srcHeight); + static void ScaleDown(uint8_t* pDestFrame, const uint16_t destWidth, const uint8_t destHeight, + const uint8_t* pSrcFrame, const uint16_t srcWidth, const uint8_t srcHeight, uint8_t bits); + static void ScaleUpIndexed(uint8_t* pDestFrame, const uint8_t* pSrcFrame, const uint16_t srcWidth, + const uint8_t srcHeight); + static void ScaleUp(uint8_t* pDestFrame, const uint8_t* pSrcFrame, const uint16_t srcWidth, const uint8_t srcHeight, + uint8_t bits); + static void CenterIndexed(uint8_t* pDestFrame, const uint16_t destWidth, const uint8_t destHeight, + const uint8_t* pSrcFrame, const uint16_t srcWidth, const uint8_t srcHeight); + static void Center(uint8_t* pDestFrame, const uint16_t destWidth, const uint8_t destHeight, const uint8_t* pSrcFrame, + const uint16_t srcWidth, const uint8_t srcHeight, uint8_t bits); +}; + +inline int Helper::MapAdafruitIndex(int x, int y, int width, int height, int numLogicalRows) +{ + int logicalRowLengthPerMatrix = 32 * 32 / 2 / numLogicalRows; + int logicalRow = y % numLogicalRows; + int dotPairsPerLogicalRow = width * height / numLogicalRows / 2; + int widthInMatrices = width / 32; + int matrixX = x / 32; + int matrixY = y / 32; + int totalMatrices = width * height / 1024; + int matrixNumber = totalMatrices - ((matrixY + 1) * widthInMatrices) + matrixX; + int indexWithinMatrixRow = x % logicalRowLengthPerMatrix; + int index = logicalRow * dotPairsPerLogicalRow + matrixNumber * logicalRowLengthPerMatrix + indexWithinMatrixRow; + return index; +} + +inline void Helper::Split(uint8_t* pPlanes, uint16_t width, uint16_t height, uint8_t bitlen, uint8_t* pFrame) +{ + int planeSize = width * height / 8; + int pos = 0; + uint8_t* bd = (uint8_t*)malloc(bitlen); + + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x += 8) + { + memset(bd, 0, bitlen * sizeof(uint8_t)); + + for (int v = 7; v >= 0; v--) + { + uint8_t pixel = pFrame[(y * width) + (x + v)]; + for (int i = 0; i < bitlen; i++) + { + bd[i] <<= 1; + if ((pixel & (1 << i)) != 0) + { + bd[i] |= 1; + } + } + } + + for (int i = 0; i < bitlen; i++) + { + pPlanes[i * planeSize + pos] = bd[i]; + } + + pos++; + } + } + + free(bd); +} + +inline void Helper::ConvertToRgb24(uint8_t* pFrameRgb24, uint8_t* pFrame, int size, uint8_t* pPalette) +{ + for (int i = 0; i < size; i++) + { + memcpy(&pFrameRgb24[i * 3], &pPalette[pFrame[i] * 3], 3); + } +} + +inline void Helper::SplitIntoRgbPlanes(const uint16_t* rgb565, int rgb565Size, int width, int numLogicalRows, + uint8_t* dest, ColorMatrix colorMatrix) +{ + constexpr int pairOffset = 16; + int height = rgb565Size / width; + int subframeSize = rgb565Size / 2; + + for (int x = 0; x < width; ++x) + { + for (int y = 0; y < height; ++y) + { + if (y % (pairOffset * 2) >= pairOffset) continue; + + int inputIndex0 = y * width + x; + int inputIndex1 = inputIndex0 + pairOffset * width; + + uint16_t color0 = rgb565[inputIndex0]; + uint16_t color1 = rgb565[inputIndex1]; + + int r0 = 0, r1 = 0, g0 = 0, g1 = 0, b0 = 0, b1 = 0; + switch (colorMatrix) + { + case ColorMatrix::Rgb: + r0 = (color0 >> 13) /*& 0x7*/; + g0 = (color0 >> 8) /*& 0x7*/; + b0 = (color0 >> 2) /*& 0x7*/; + r1 = (color1 >> 13) /*& 0x7*/; + g1 = (color1 >> 8) /*& 0x7*/; + b1 = (color1 >> 2) /*& 0x7*/; + break; + + case ColorMatrix::Rbg: + r0 = (color0 >> 13) /*& 0x7*/; + b0 = (color0 >> 8) /*& 0x7*/; + g0 = (color0 >> 2) /*& 0x7*/; + r1 = (color1 >> 13) /*& 0x7*/; + b1 = (color1 >> 8) /*& 0x7*/; + g1 = (color1 >> 2) /*& 0x7*/; + break; + } + + for (int subframe = 0; subframe < 3; ++subframe) + { + uint8_t dotPair = (r0 & 1) << 5 | (g0 & 1) << 4 | (b0 & 1) << 3 | (r1 & 1) << 2 | (g1 & 1) << 1 | (b1 & 1); + int indexWithinSubframe = MapAdafruitIndex(x, y, width, height, numLogicalRows); + int indexWithinOutput = subframe * subframeSize + indexWithinSubframe; + dest[indexWithinOutput] = dotPair; + r0 >>= 1; + g0 >>= 1; + b0 >>= 1; + r1 >>= 1; + g1 >>= 1; + b1 >>= 1; + } + } + } +} + +inline float Helper::CalcBrightness(float x) +{ + // function to improve the brightness with fx=ax²+bc+c, f(0)=0, f(1)=1, f'(1.1)=0 + return (-x * x + 2.1f * x) / 1.1f; +} + +inline void Helper::ScaleDownIndexed(uint8_t* pDestFrame, const uint16_t destWidth, const uint8_t destHeight, + const uint8_t* pSrcFrame, const uint16_t srcWidth, const uint8_t srcHeight) +{ + memset(pDestFrame, 0, destWidth * destHeight); + uint8_t xOffset = (destWidth - (srcWidth / 2)) / 2; + uint8_t yOffset = (destHeight - (srcHeight / 2)) / 2; + + // for half scaling we take the 4 points and look if there is one color repeated + for (uint8_t y = 0; y < srcHeight; y += 2) + { + std::vector row; + row.reserve(srcWidth / 2); + + for (uint16_t x = 0; x < srcWidth; x += 2) + { + uint8_t upper_left = pSrcFrame[y * srcWidth + x]; + uint8_t upper_right = pSrcFrame[y * srcWidth + x + 1]; + uint8_t lower_left = pSrcFrame[(y + 1) * srcWidth + x]; + uint8_t lower_right = pSrcFrame[(y + 1) * srcWidth + x + 1]; + + if (x < srcWidth / 2) + { + if (y < srcHeight / 2) + { + if (upper_left == upper_right || upper_left == lower_left || upper_left == lower_right) + row.push_back(upper_left); + else if (upper_right == lower_left || upper_right == lower_right) + row.push_back(upper_right); + else if (lower_left == lower_right) + row.push_back(lower_left); + else + row.push_back(upper_left); + } + else + { + if (lower_left == lower_right || lower_left == upper_left || lower_left == upper_right) + row.push_back(lower_right); + else if (lower_right == upper_left || lower_right == upper_right) + row.push_back(lower_right); + else if (upper_left == upper_right) + row.push_back(upper_left); + else + row.push_back(lower_left); + } + } + else + { + if (y < srcHeight / 2) + { + if (upper_right == upper_left || upper_right == lower_right || upper_right == lower_left) + row.push_back(upper_right); + else if (upper_left == lower_right || upper_left == lower_left) + row.push_back(upper_left); + else if (lower_right == lower_left) + row.push_back(lower_right); + else + row.push_back(upper_right); + } + else + { + if (lower_right == lower_left || lower_right == upper_right || lower_right == upper_left) + row.push_back(lower_right); + else if (lower_left == upper_right || lower_left == upper_left) + row.push_back(lower_left); + else if (upper_right == upper_left) + row.push_back(upper_right); + else + row.push_back(lower_right); + } + } + } + + memcpy(&pDestFrame[(yOffset + (y / 2)) * destWidth + xOffset], row.data(), srcWidth / 2); + } +} + +inline void Helper::ScaleDownPUP(uint8_t* pDestFrame, const uint16_t destWidth, const uint8_t destHeight, + const uint8_t* pSrcFrame, const uint16_t srcWidth, const uint8_t srcHeight) +{ + memset(pDestFrame, 0, destWidth * destHeight); + uint8_t xOffset = (destWidth - (srcWidth / 2)) / 2; + uint8_t yOffset = (destHeight - (srcHeight / 2)) / 2; + + // for half scaling we take the 4 points and look if there is one color repeated + for (uint8_t y = 0; y < srcHeight; y += 2) + { + std::vector row; + row.reserve(srcWidth / 2); + + for (uint16_t x = 0; x < srcWidth; x += 2) + { + uint8_t pixel1 = pSrcFrame[y * srcWidth + x]; + uint8_t pixel2 = pSrcFrame[y * srcWidth + x + 1]; + uint8_t pixel3 = pSrcFrame[(y + 1) * srcWidth + x]; + uint8_t pixel4 = pSrcFrame[(y + 1) * srcWidth + x + 1]; + + if (pixel1 == pixel2 || pixel1 == pixel3 || pixel1 == pixel4) + row.push_back(pixel1); + else if (pixel2 == pixel3 || pixel2 == pixel4) + row.push_back(pixel2); + else if (pixel3 == pixel4) + row.push_back(pixel3); + else + row.push_back(pixel1); + } + + memcpy(&pDestFrame[(yOffset + (y / 2)) * destWidth + xOffset], row.data(), srcWidth / 2); + } +} + +inline void Helper::ScaleDown(uint8_t* pDestFrame, const uint16_t destWidth, const uint8_t destHeight, + const uint8_t* pSrcFrame, const uint16_t srcWidth, const uint8_t srcHeight, uint8_t bits) +{ + memset(pDestFrame, 0, destWidth * destHeight); + uint8_t xOffset = (destWidth - (srcWidth / 2)) / 2; + uint8_t yOffset = (destHeight - (srcHeight / 2)) / 2; + uint8_t bytes = bits / 8; // RGB24 (3 byte) or RGB16 (2 byte) + + for (uint8_t y = 0; y < srcHeight; y += 2) + { + for (uint16_t x = 0; x < srcWidth; x += 2) + { + uint16_t upper_left = y * srcWidth * bytes + x * bytes; + uint16_t upper_right = upper_left + bytes; + uint16_t lower_left = upper_left + srcWidth * bytes; + uint16_t lower_right = lower_left + bytes; + uint16_t target = (xOffset + (x / 2) + (y / 2) * destHeight) * bytes; + + if (x < srcWidth / 2) + { + if (y < srcHeight / 2) + { + if (memcmp(&pSrcFrame[upper_left], &pSrcFrame[upper_right], bytes) == 0 || + memcmp(&pSrcFrame[upper_left], &pSrcFrame[lower_left], bytes) == 0 || + memcmp(&pSrcFrame[upper_left], &pSrcFrame[lower_right], bytes) == 0) + memcpy(&pDestFrame[target], &pSrcFrame[upper_left], bytes); + else if (memcmp(&pSrcFrame[upper_right], &pSrcFrame[lower_left], bytes) == 0 || + memcmp(&pSrcFrame[upper_right], &pSrcFrame[lower_right], bytes) == 0) + memcpy(&pDestFrame[target], &pSrcFrame[upper_right], bytes); + else if (memcmp(&pSrcFrame[lower_left], &pSrcFrame[lower_right], bytes) == 0) + memcpy(&pDestFrame[target], &pSrcFrame[lower_left], bytes); + else + memcpy(&pDestFrame[target], &pSrcFrame[upper_left], bytes); + } + else + { + if (memcmp(&pSrcFrame[lower_left], &pSrcFrame[lower_right], bytes) == 0 || + memcmp(&pSrcFrame[lower_left], &pSrcFrame[upper_left], bytes) == 0 || + memcmp(&pSrcFrame[lower_left], &pSrcFrame[upper_right], bytes) == 0) + memcpy(&pDestFrame[target], &pSrcFrame[lower_left], bytes); + else if (memcmp(&pSrcFrame[lower_right], &pSrcFrame[upper_left], bytes) == 0 || + memcmp(&pSrcFrame[lower_right], &pSrcFrame[upper_right], bytes) == 0) + memcpy(&pDestFrame[target], &pSrcFrame[lower_right], bytes); + else if (memcmp(&pSrcFrame[upper_left], &pSrcFrame[upper_right], bytes) == 0) + memcpy(&pDestFrame[target], &pSrcFrame[upper_left], bytes); + else + memcpy(&pDestFrame[target], &pSrcFrame[lower_left], bytes); + } + } + else + { + if (y < srcHeight / 2) + { + if (memcmp(&pSrcFrame[upper_right], &pSrcFrame[upper_left], bytes) == 0 || + memcmp(&pSrcFrame[upper_right], &pSrcFrame[lower_right], bytes) == 0 || + memcmp(&pSrcFrame[upper_right], &pSrcFrame[lower_left], bytes) == 0) + memcpy(&pDestFrame[target], &pSrcFrame[upper_right], bytes); + else if (memcmp(&pSrcFrame[upper_left], &pSrcFrame[lower_right], bytes) == 0 || + memcmp(&pSrcFrame[upper_left], &pSrcFrame[lower_left], bytes) == 0) + memcpy(&pDestFrame[target], &pSrcFrame[upper_left], bytes); + else if (memcmp(&pSrcFrame[lower_right], &pSrcFrame[lower_left], bytes) == 0) + memcpy(&pDestFrame[target], &pSrcFrame[lower_right], bytes); + else + memcpy(&pDestFrame[target], &pSrcFrame[upper_right], bytes); + } + else + { + if (memcmp(&pSrcFrame[lower_right], &pSrcFrame[lower_left], bytes) == 0 || + memcmp(&pSrcFrame[lower_right], &pSrcFrame[upper_right], bytes) == 0 || + memcmp(&pSrcFrame[lower_right], &pSrcFrame[upper_left], bytes) == 0) + memcpy(&pDestFrame[target], &pSrcFrame[lower_right], bytes); + else if (memcmp(&pSrcFrame[lower_left], &pSrcFrame[upper_right], bytes) == 0 || + memcmp(&pSrcFrame[lower_left], &pSrcFrame[upper_left], bytes) == 0) + memcpy(&pDestFrame[target], &pSrcFrame[lower_left], bytes); + else if (memcmp(&pSrcFrame[upper_right], &pSrcFrame[upper_left], bytes) == 0) + memcpy(&pDestFrame[target], &pSrcFrame[upper_right], bytes); + else + memcpy(&pDestFrame[target], &pSrcFrame[lower_right], bytes); + } + } + } + } +} + +inline void Helper::ScaleUp(uint8_t* pDestFrame, const uint8_t* pSrcFrame, const uint16_t srcWidth, + const uint8_t srcHeight, uint8_t bits) +{ + uint8_t bytes = bits / 8; // RGB24 (3 byte) or RGB16 (2 byte) or indexed (1 byte) + uint16_t destWidth = srcWidth * 2; + memset(pDestFrame, 0, srcWidth * srcHeight * 4 * bytes); + + // we implement scale2x http://www.scale2x.it/algorithm + uint16_t row = srcWidth * bytes; + uint8_t* a = (uint8_t*)malloc(bytes); + uint8_t* b = (uint8_t*)malloc(bytes); + uint8_t* c = (uint8_t*)malloc(bytes); + uint8_t* d = (uint8_t*)malloc(bytes); + uint8_t* e = (uint8_t*)malloc(bytes); + uint8_t* f = (uint8_t*)malloc(bytes); + uint8_t* g = (uint8_t*)malloc(bytes); + uint8_t* h = (uint8_t*)malloc(bytes); + uint8_t* i = (uint8_t*)malloc(bytes); + + for (uint16_t y = 0; y < srcHeight; y++) + { + for (uint16_t x = 0; x < srcWidth; x++) + { + for (uint8_t tc = 0; tc < bytes; tc++) + { + if (x == 0 && y == 0) + { + a[tc] = b[tc] = d[tc] = e[tc] = pSrcFrame[tc]; + c[tc] = f[tc] = pSrcFrame[bytes + tc]; + g[tc] = h[tc] = pSrcFrame[row + tc]; + i[tc] = pSrcFrame[row + bytes + tc]; + } + else if ((x == 0) && (y == srcHeight - 1)) + { + a[tc] = b[tc] = pSrcFrame[(y - 1) * row + tc]; + c[tc] = pSrcFrame[(y - 1) * row + bytes + tc]; + d[tc] = g[tc] = h[tc] = e[tc] = pSrcFrame[y * row + tc]; + f[tc] = i[tc] = pSrcFrame[y * row + bytes + tc]; + } + else if ((x == srcWidth - 1) && (y == 0)) + { + a[tc] = d[tc] = pSrcFrame[x * bytes - bytes + tc]; + b[tc] = c[tc] = f[tc] = e[tc] = pSrcFrame[x * bytes + tc]; + g[tc] = pSrcFrame[row + x * bytes - bytes + tc]; + h[tc] = i[tc] = pSrcFrame[row + x * bytes + tc]; + } + else if ((x == srcWidth - 1) && (y == srcHeight - 1)) + { + a[tc] = pSrcFrame[y * row - 2 * bytes + tc]; + b[tc] = c[tc] = pSrcFrame[y * row - bytes + tc]; + d[tc] = g[tc] = pSrcFrame[srcHeight * row - 2 * bytes + tc]; + e[tc] = f[tc] = h[tc] = i[tc] = pSrcFrame[srcHeight * row - bytes + tc]; + } + else if (x == 0) + { + a[tc] = b[tc] = pSrcFrame[(y - 1) * row + tc]; + c[tc] = pSrcFrame[(y - 1) * row + bytes + tc]; + d[tc] = e[tc] = pSrcFrame[y * row + tc]; + f[tc] = pSrcFrame[y * row + bytes + tc]; + g[tc] = h[tc] = pSrcFrame[(y + 1) * row + tc]; + i[tc] = pSrcFrame[(y + 1) * row + bytes + tc]; + } + else if (x == srcWidth - 1) + { + a[tc] = pSrcFrame[y * row - 2 * bytes + tc]; + b[tc] = c[tc] = pSrcFrame[y * row - bytes + tc]; + d[tc] = pSrcFrame[(y + 1) * row - 2 * bytes + tc]; + e[tc] = f[tc] = pSrcFrame[(y + 1) * row - bytes + tc]; + g[tc] = pSrcFrame[(y + 2) * row - 2 * bytes + tc]; + h[tc] = i[tc] = pSrcFrame[(y + 2) * row - bytes + tc]; + } + else if (y == 0) + { + a[tc] = d[tc] = pSrcFrame[x * bytes - bytes + tc]; + b[tc] = e[tc] = pSrcFrame[x * bytes + tc]; + c[tc] = f[tc] = pSrcFrame[x * bytes + bytes + tc]; + g[tc] = pSrcFrame[row + x * bytes - bytes + tc]; + h[tc] = pSrcFrame[row + x * bytes + tc]; + i[tc] = pSrcFrame[row + x * bytes + bytes + tc]; + } + else if (y == srcHeight - 1) + { + a[tc] = pSrcFrame[(y - 1) * row + x * bytes - bytes + tc]; + b[tc] = pSrcFrame[(y - 1) * row + x * bytes + tc]; + c[tc] = pSrcFrame[(y - 1) * row + x * bytes + bytes + tc]; + d[tc] = g[tc] = pSrcFrame[y * row + x * bytes - bytes + tc]; + e[tc] = h[tc] = pSrcFrame[y * row + x * bytes + tc]; + f[tc] = i[tc] = pSrcFrame[y * row + x * bytes + bytes + tc]; + } + else + { + a[tc] = pSrcFrame[(y - 1) * row + x * bytes - bytes + tc]; + b[tc] = pSrcFrame[(y - 1) * row + x * bytes + tc]; + c[tc] = pSrcFrame[(y - 1) * row + x * bytes + bytes + tc]; + d[tc] = pSrcFrame[y * row + x * bytes - bytes + tc]; + e[tc] = pSrcFrame[y * row + x * bytes + tc]; + f[tc] = pSrcFrame[y * row + x * bytes + bytes + tc]; + g[tc] = pSrcFrame[(y + 1) * row + x * bytes - bytes + tc]; + h[tc] = pSrcFrame[(y + 1) * row + x * bytes + tc]; + i[tc] = pSrcFrame[(y + 1) * row + x * bytes + bytes + tc]; + } + } + + if (memcmp(b, h, bytes) != 0 && memcmp(d, f, bytes) != 0) + { + memcpy(&pDestFrame[(y * 2 * destWidth + x * 2) * bytes], memcmp(d, b, bytes) == 0 ? d : e, bytes); + memcpy(&pDestFrame[(y * 2 * destWidth + x * 2 + 1) * bytes], memcmp(b, f, bytes) == 0 ? f : e, bytes); + memcpy(&pDestFrame[((y * 2 + 1) * destWidth + x * 2) * bytes], memcmp(d, h, bytes) == 0 ? d : e, bytes); + memcpy(&pDestFrame[((y * 2 + 1) * destWidth + x * 2 + 1) * bytes], memcmp(h, f, bytes) == 0 ? f : e, bytes); + } + else + { + memcpy(&pDestFrame[(y * 2 * destWidth + x * 2) * bytes], e, bytes); + memcpy(&pDestFrame[(y * 2 * destWidth + x * 2 + 1) * bytes], e, bytes); + memcpy(&pDestFrame[((y * 2 + 1) * destWidth + x * 2) * bytes], e, bytes); + memcpy(&pDestFrame[((y * 2 + 1) * destWidth + x * 2 + 1) * bytes], e, bytes); + } + } + } + + free(a); + free(b); + free(c); + free(d); + free(e); + free(f); + free(g); + free(h); + free(i); +} + +inline void Helper::ScaleUpIndexed(uint8_t* pDestFrame, const uint8_t* pSrcFrame, const uint16_t srcWidth, + const uint8_t srcHeight) +{ + ScaleUp(pDestFrame, pSrcFrame, srcWidth, srcHeight, 8); +} + +inline void Helper::Center(uint8_t* pDestFrame, const uint16_t destWidth, const uint8_t destHeight, + const uint8_t* pSrcFrame, const uint16_t srcWidth, const uint8_t srcHeight, uint8_t bits) +{ + uint8_t bytes = bits / 8; // RGB24 (3 byte) or RGB16 (2 byte) or indexed (1 byte) + + memset(pDestFrame, 0, destWidth * destHeight * bytes); + uint8_t xOffset = (destWidth - srcWidth) / 2; + uint8_t yOffset = (destHeight - srcHeight) / 2; + + for (uint8_t y = 0; y < srcHeight; y++) + { + memcpy(&pDestFrame[((yOffset + y) * destWidth + xOffset) * bytes], &pSrcFrame[y * srcWidth * bytes], + srcWidth * bytes); + } +} + +inline void Helper::CenterIndexed(uint8_t* pDestFrame, const uint16_t destWidth, const uint8_t destHeight, + const uint8_t* pSrcFrame, const uint16_t srcWidth, const uint8_t srcHeight) +{ + Center(pDestFrame, destWidth, destHeight, pSrcFrame, srcWidth, srcHeight, 8); +} + +} // namespace FrameUtil From 4c21bde2df33ae091238450f855f96a728f389c3 Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Wed, 3 Apr 2024 18:21:58 +0200 Subject: [PATCH 5/6] still fetch libframeutil in case an update is required --- .gitignore | 8 +++++++- platforms/android/arm64-v8a/external.sh | 12 ++++++++++++ platforms/ios/arm64/external.sh | 12 ++++++++++++ platforms/linux/aarch64/external.sh | 12 ++++++++++++ platforms/linux/x64/external.sh | 12 ++++++++++++ platforms/macos/arm64/external.sh | 12 ++++++++++++ platforms/macos/x64/external.sh | 12 ++++++++++++ platforms/tvos/arm64/external.sh | 12 ++++++++++++ platforms/win/x64/external.sh | 12 ++++++++++++ platforms/win/x86/external.sh | 12 ++++++++++++ third-party/include/.gitkeep | 0 11 files changed, 115 insertions(+), 1 deletion(-) delete mode 100644 third-party/include/.gitkeep diff --git a/.gitignore b/.gitignore index 7e627bd..10a8428 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,11 @@ external.sh external third-party/runtime-libs third-party/build-libs -third-party/include +third-party/include/sockpp +third-party/include/cargs.h +third-party/include/*.hpp +third-party/include/libserialport.h +third-party/include/pupdmd.h +third-party/include/serum-decode.h +third-party/include/ZeDMD.h .DS_Store diff --git a/platforms/android/arm64-v8a/external.sh b/platforms/android/arm64-v8a/external.sh index 7e64cd9..10ff73c 100755 --- a/platforms/android/arm64-v8a/external.sh +++ b/platforms/android/arm64-v8a/external.sh @@ -7,6 +7,7 @@ LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c +LIBFRAMEUTIL_SHA=d9bde3069786f1a33d2021afe19566d812e873f5 if [[ $(uname) == "Linux" ]]; then NUM_PROCS=$(nproc) @@ -22,6 +23,7 @@ echo " LIBZEDMD_SHA: ${LIBZEDMD_SHA}" echo " LIBSERUM_SHA: ${LIBSERUM_SHA}" echo " SOCKPP_SHA: ${SOCKPP_SHA}" echo " LIBPUPDMD_SHA: ${LIBPUPDMD_SHA}" +echo " LIBFRAMEUTIL_SHA: ${LIBFRAMEUTIL_SHA}" echo " NUM_PROCS: ${NUM_PROCS}" echo "" @@ -138,3 +140,13 @@ cmake --build build -- -j${NUM_PROCS} cp src/pupdmd.h ../../third-party/include/ cp build/libpupdmd.so ../../third-party/runtime-libs/android/arm64-v8a/ cd .. + +# +# copy libframeutil +# + +curl -sL https://github.com/ppuc/libframeutil/archive/${LIBFRAMEUTIL_SHA}.zip -o libframeutil.zip +unzip libframeutil.zip +cd libframeutil-$LIBFRAMEUTIL_SHA +cp include/* ../../third-party/include +cd .. diff --git a/platforms/ios/arm64/external.sh b/platforms/ios/arm64/external.sh index 62ff27f..7634b38 100755 --- a/platforms/ios/arm64/external.sh +++ b/platforms/ios/arm64/external.sh @@ -7,6 +7,7 @@ LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c +LIBFRAMEUTIL_SHA=d9bde3069786f1a33d2021afe19566d812e873f5 NUM_PROCS=$(sysctl -n hw.ncpu) @@ -16,6 +17,7 @@ echo " LIBZEDMD_SHA: ${LIBZEDMD_SHA}" echo " LIBSERUM_SHA: ${LIBSERUM_SHA}" echo " SOCKPP_SHA: ${SOCKPP_SHA}" echo " LIBPUPDMD_SHA: ${LIBPUPDMD_SHA}" +echo " LIBFRAMEUTIL_SHA: ${LIBFRAMEUTIL_SHA}" echo "" if [ -z "${BUILD_TYPE}" ]; then @@ -123,3 +125,13 @@ cmake --build build -- -j${NUM_PROCS} cp src/pupdmd.h ../../third-party/include/ cp build/libpupdmd.a ../../third-party/build-libs/ios/arm64/ cd .. + +# +# copy libframeutil +# + +curl -sL https://github.com/ppuc/libframeutil/archive/${LIBFRAMEUTIL_SHA}.zip -o libframeutil.zip +unzip libframeutil.zip +cd libframeutil-$LIBFRAMEUTIL_SHA +cp include/* ../../third-party/include +cd .. diff --git a/platforms/linux/aarch64/external.sh b/platforms/linux/aarch64/external.sh index 56c6991..1558431 100755 --- a/platforms/linux/aarch64/external.sh +++ b/platforms/linux/aarch64/external.sh @@ -7,6 +7,7 @@ LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c +LIBFRAMEUTIL_SHA=d9bde3069786f1a33d2021afe19566d812e873f5 NUM_PROCS=$(nproc) @@ -16,6 +17,7 @@ echo " LIBZEDMD_SHA: ${LIBZEDMD_SHA}" echo " LIBSERUM_SHA: ${LIBSERUM_SHA}" echo " SOCKPP_SHA: ${SOCKPP_SHA}" echo " LIBPUPDMD_SHA: ${LIBPUPDMD_SHA}" +echo " LIBFRAMEUTIL_SHA: ${LIBFRAMEUTIL_SHA}" echo "" if [ -z "${BUILD_TYPE}" ]; then @@ -123,3 +125,13 @@ cmake --build build -- -j${NUM_PROCS} cp src/pupdmd.h ../../third-party/include/ cp -a build/libpupdmd.{so,so.*} ../../third-party/runtime-libs/linux/aarch64/ cd .. + +# +# copy libframeutil +# + +curl -sL https://github.com/ppuc/libframeutil/archive/${LIBFRAMEUTIL_SHA}.zip -o libframeutil.zip +unzip libframeutil.zip +cd libframeutil-$LIBFRAMEUTIL_SHA +cp include/* ../../third-party/include +cd .. diff --git a/platforms/linux/x64/external.sh b/platforms/linux/x64/external.sh index f36bd6f..aa34c61 100755 --- a/platforms/linux/x64/external.sh +++ b/platforms/linux/x64/external.sh @@ -7,6 +7,7 @@ LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c +LIBFRAMEUTIL_SHA=d9bde3069786f1a33d2021afe19566d812e873f5 NUM_PROCS=$(nproc) @@ -16,6 +17,7 @@ echo " LIBZEDMD_SHA: ${LIBZEDMD_SHA}" echo " LIBSERUM_SHA: ${LIBSERUM_SHA}" echo " SOCKPP_SHA: ${SOCKPP_SHA}" echo " LIBPUPDMD_SHA: ${LIBPUPDMD_SHA}" +echo " LIBFRAMEUTIL_SHA: ${LIBFRAMEUTIL_SHA}" echo "" if [ -z "${BUILD_TYPE}" ]; then @@ -123,3 +125,13 @@ cmake --build build -- -j${NUM_PROCS} cp src/pupdmd.h ../../third-party/include/ cp -a build/libpupdmd.{so,so.*} ../../third-party/runtime-libs/linux/x64/ cd .. + +# +# copy libframeutil +# + +curl -sL https://github.com/ppuc/libframeutil/archive/${LIBFRAMEUTIL_SHA}.zip -o libframeutil.zip +unzip libframeutil.zip +cd libframeutil-$LIBFRAMEUTIL_SHA +cp include/* ../../third-party/include +cd .. diff --git a/platforms/macos/arm64/external.sh b/platforms/macos/arm64/external.sh index 367af95..33f8189 100755 --- a/platforms/macos/arm64/external.sh +++ b/platforms/macos/arm64/external.sh @@ -7,6 +7,7 @@ LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c +LIBFRAMEUTIL_SHA=d9bde3069786f1a33d2021afe19566d812e873f5 NUM_PROCS=$(sysctl -n hw.ncpu) @@ -16,6 +17,7 @@ echo " LIBZEDMD_SHA: ${LIBZEDMD_SHA}" echo " LIBSERUM_SHA: ${LIBSERUM_SHA}" echo " SOCKPP_SHA: ${SOCKPP_SHA}" echo " LIBPUPDMD_SHA: ${LIBPUPDMD_SHA}" +echo " LIBFRAMEUTIL_SHA: ${LIBFRAMEUTIL_SHA}" echo "" if [ -z "${BUILD_TYPE}" ]; then @@ -127,3 +129,13 @@ cmake --build build -- -j${NUM_PROCS} cp src/pupdmd.h ../../third-party/include/ cp -a build/*.dylib ../../third-party/runtime-libs/macos/arm64/ cd .. + +# +# copy libframeutil +# + +curl -sL https://github.com/ppuc/libframeutil/archive/${LIBFRAMEUTIL_SHA}.zip -o libframeutil.zip +unzip libframeutil.zip +cd libframeutil-$LIBFRAMEUTIL_SHA +cp include/* ../../third-party/include +cd .. diff --git a/platforms/macos/x64/external.sh b/platforms/macos/x64/external.sh index 4673e61..c7415fd 100755 --- a/platforms/macos/x64/external.sh +++ b/platforms/macos/x64/external.sh @@ -7,6 +7,7 @@ LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c +LIBFRAMEUTIL_SHA=d9bde3069786f1a33d2021afe19566d812e873f5 NUM_PROCS=$(sysctl -n hw.ncpu) @@ -16,6 +17,7 @@ echo " LIBZEDMD_SHA: ${LIBZEDMD_SHA}" echo " LIBSERUM_SHA: ${LIBSERUM_SHA}" echo " SOCKPP_SHA: ${SOCKPP_SHA}" echo " LIBPUPDMD_SHA: ${LIBPUPDMD_SHA}" +echo " LIBFRAMEUTIL_SHA: ${LIBFRAMEUTIL_SHA}" echo "" if [ -z "${BUILD_TYPE}" ]; then @@ -127,3 +129,13 @@ cmake --build build -- -j${NUM_PROCS} cp src/pupdmd.h ../../third-party/include/ cp -a build/*.dylib ../../third-party/runtime-libs/macos/x64/ cd .. + +# +# copy libframeutil +# + +curl -sL https://github.com/ppuc/libframeutil/archive/${LIBFRAMEUTIL_SHA}.zip -o libframeutil.zip +unzip libframeutil.zip +cd libframeutil-$LIBFRAMEUTIL_SHA +cp include/* ../../third-party/include +cd .. diff --git a/platforms/tvos/arm64/external.sh b/platforms/tvos/arm64/external.sh index b7933be..5ba0b8c 100755 --- a/platforms/tvos/arm64/external.sh +++ b/platforms/tvos/arm64/external.sh @@ -7,6 +7,7 @@ LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c +LIBFRAMEUTIL_SHA=d9bde3069786f1a33d2021afe19566d812e873f5 NUM_PROCS=$(sysctl -n hw.ncpu) @@ -16,6 +17,7 @@ echo " LIBZEDMD_SHA: ${LIBZEDMD_SHA}" echo " LIBSERUM_SHA: ${LIBSERUM_SHA}" echo " SOCKPP_SHA: ${SOCKPP_SHA}" echo " LIBPUPDMD_SHA: ${LIBPUPDMD_SHA}" +echo " LIBFRAMEUTIL_SHA: ${LIBFRAMEUTIL_SHA}" echo "" if [ -z "${BUILD_TYPE}" ]; then @@ -123,3 +125,13 @@ cmake --build build -- -j${NUM_PROCS} cp src/pupdmd.h ../../third-party/include/ cp build/libpupdmd.a ../../third-party/build-libs/tvos/arm64/ cd .. + +# +# copy libframeutil +# + +curl -sL https://github.com/ppuc/libframeutil/archive/${LIBFRAMEUTIL_SHA}.zip -o libframeutil.zip +unzip libframeutil.zip +cd libframeutil-$LIBFRAMEUTIL_SHA +cp include/* ../../third-party/include +cd .. diff --git a/platforms/win/x64/external.sh b/platforms/win/x64/external.sh index 8fef3b1..98b365b 100755 --- a/platforms/win/x64/external.sh +++ b/platforms/win/x64/external.sh @@ -7,6 +7,7 @@ LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c +LIBFRAMEUTIL_SHA=d9bde3069786f1a33d2021afe19566d812e873f5 echo "Building libraries..." echo " CARGS_SHA: ${CARGS_SHA}" @@ -14,6 +15,7 @@ echo " LIBZEDMD_SHA: ${LIBZEDMD_SHA}" echo " LIBSERUM_SHA: ${LIBSERUM_SHA}" echo " SOCKPP_SHA: ${SOCKPP_SHA}" echo " LIBPUPDMD_SHA: ${LIBPUPDMD_SHA}" +echo " LIBFRAMEUTIL_SHA: ${LIBFRAMEUTIL_SHA}" echo "" if [ -z "${BUILD_TYPE}" ]; then @@ -126,3 +128,13 @@ cp src/pupdmd.h ../../third-party/include/ cp build/${BUILD_TYPE}/pupdmd64.lib ../../third-party/build-libs/win/x64/ cp build/${BUILD_TYPE}/pupdmd64.dll ../../third-party/runtime-libs/win/x64/ cd .. + +# +# copy libframeutil +# + +curl -sL https://github.com/ppuc/libframeutil/archive/${LIBFRAMEUTIL_SHA}.zip -o libframeutil.zip +unzip libframeutil.zip +cd libframeutil-$LIBFRAMEUTIL_SHA +cp include/* ../../third-party/include +cd .. diff --git a/platforms/win/x86/external.sh b/platforms/win/x86/external.sh index 774ad8b..368ef89 100755 --- a/platforms/win/x86/external.sh +++ b/platforms/win/x86/external.sh @@ -7,6 +7,7 @@ LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c +LIBFRAMEUTIL_SHA=d9bde3069786f1a33d2021afe19566d812e873f5 echo "Building libraries..." echo " CARGS_SHA: ${CARGS_SHA}" @@ -14,6 +15,7 @@ echo " LIBZEDMD_SHA: ${LIBZEDMD_SHA}" echo " LIBSERUM_SHA: ${LIBSERUM_SHA}" echo " SOCKPP_SHA: ${SOCKPP_SHA}" echo " LIBPUPDMD_SHA: ${LIBPUPDMD_SHA}" +echo " LIBFRAMEUTIL_SHA: ${LIBFRAMEUTIL_SHA}" echo "" if [ -z "${BUILD_TYPE}" ]; then @@ -129,3 +131,13 @@ cp src/pupdmd.h ../../third-party/include/ cp build/${BUILD_TYPE}/pupdmd.lib ../../third-party/build-libs/win/x86/ cp build/${BUILD_TYPE}/pupdmd.dll ../../third-party/runtime-libs/win/x86/ cd .. + +# +# copy libframeutil +# + +curl -sL https://github.com/ppuc/libframeutil/archive/${LIBFRAMEUTIL_SHA}.zip -o libframeutil.zip +unzip libframeutil.zip +cd libframeutil-$LIBFRAMEUTIL_SHA +cp include/* ../../third-party/include +cd .. diff --git a/third-party/include/.gitkeep b/third-party/include/.gitkeep deleted file mode 100644 index e69de29..0000000 From b92627f0196535af9a8fa789ff72ac4bf240df65 Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Wed, 3 Apr 2024 18:29:35 +0200 Subject: [PATCH 6/6] inew lib versions --- platforms/android/arm64-v8a/external.sh | 4 ++-- platforms/ios/arm64/external.sh | 4 ++-- platforms/linux/aarch64/external.sh | 4 ++-- platforms/linux/x64/external.sh | 4 ++-- platforms/macos/arm64/external.sh | 4 ++-- platforms/macos/x64/external.sh | 4 ++-- platforms/tvos/arm64/external.sh | 4 ++-- platforms/win/x64/external.sh | 4 ++-- platforms/win/x86/external.sh | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/platforms/android/arm64-v8a/external.sh b/platforms/android/arm64-v8a/external.sh index 10ff73c..9138702 100755 --- a/platforms/android/arm64-v8a/external.sh +++ b/platforms/android/arm64-v8a/external.sh @@ -3,10 +3,10 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd +LIBZEDMD_SHA=984ac9b14824d3924455c64f36c512e5b35852b7 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f -LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c +LIBPUPDMD_SHA=c640ea2cec94097e8baefee9dab39266970e4405 LIBFRAMEUTIL_SHA=d9bde3069786f1a33d2021afe19566d812e873f5 if [[ $(uname) == "Linux" ]]; then diff --git a/platforms/ios/arm64/external.sh b/platforms/ios/arm64/external.sh index 7634b38..6f28462 100755 --- a/platforms/ios/arm64/external.sh +++ b/platforms/ios/arm64/external.sh @@ -3,10 +3,10 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd +LIBZEDMD_SHA=984ac9b14824d3924455c64f36c512e5b35852b7 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f -LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c +LIBPUPDMD_SHA=c640ea2cec94097e8baefee9dab39266970e4405 LIBFRAMEUTIL_SHA=d9bde3069786f1a33d2021afe19566d812e873f5 NUM_PROCS=$(sysctl -n hw.ncpu) diff --git a/platforms/linux/aarch64/external.sh b/platforms/linux/aarch64/external.sh index 1558431..9d5f33d 100755 --- a/platforms/linux/aarch64/external.sh +++ b/platforms/linux/aarch64/external.sh @@ -3,10 +3,10 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd +LIBZEDMD_SHA=984ac9b14824d3924455c64f36c512e5b35852b7 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f -LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c +LIBPUPDMD_SHA=c640ea2cec94097e8baefee9dab39266970e4405 LIBFRAMEUTIL_SHA=d9bde3069786f1a33d2021afe19566d812e873f5 NUM_PROCS=$(nproc) diff --git a/platforms/linux/x64/external.sh b/platforms/linux/x64/external.sh index aa34c61..994e0d5 100755 --- a/platforms/linux/x64/external.sh +++ b/platforms/linux/x64/external.sh @@ -3,10 +3,10 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd +LIBZEDMD_SHA=984ac9b14824d3924455c64f36c512e5b35852b7 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f -LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c +LIBPUPDMD_SHA=c640ea2cec94097e8baefee9dab39266970e4405 LIBFRAMEUTIL_SHA=d9bde3069786f1a33d2021afe19566d812e873f5 NUM_PROCS=$(nproc) diff --git a/platforms/macos/arm64/external.sh b/platforms/macos/arm64/external.sh index 33f8189..6072878 100755 --- a/platforms/macos/arm64/external.sh +++ b/platforms/macos/arm64/external.sh @@ -3,10 +3,10 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd +LIBZEDMD_SHA=984ac9b14824d3924455c64f36c512e5b35852b7 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f -LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c +LIBPUPDMD_SHA=c640ea2cec94097e8baefee9dab39266970e4405 LIBFRAMEUTIL_SHA=d9bde3069786f1a33d2021afe19566d812e873f5 NUM_PROCS=$(sysctl -n hw.ncpu) diff --git a/platforms/macos/x64/external.sh b/platforms/macos/x64/external.sh index c7415fd..ea08932 100755 --- a/platforms/macos/x64/external.sh +++ b/platforms/macos/x64/external.sh @@ -3,10 +3,10 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd +LIBZEDMD_SHA=984ac9b14824d3924455c64f36c512e5b35852b7 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f -LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c +LIBPUPDMD_SHA=c640ea2cec94097e8baefee9dab39266970e4405 LIBFRAMEUTIL_SHA=d9bde3069786f1a33d2021afe19566d812e873f5 NUM_PROCS=$(sysctl -n hw.ncpu) diff --git a/platforms/tvos/arm64/external.sh b/platforms/tvos/arm64/external.sh index 5ba0b8c..f05fc59 100755 --- a/platforms/tvos/arm64/external.sh +++ b/platforms/tvos/arm64/external.sh @@ -3,10 +3,10 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd +LIBZEDMD_SHA=984ac9b14824d3924455c64f36c512e5b35852b7 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f -LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c +LIBPUPDMD_SHA=c640ea2cec94097e8baefee9dab39266970e4405 LIBFRAMEUTIL_SHA=d9bde3069786f1a33d2021afe19566d812e873f5 NUM_PROCS=$(sysctl -n hw.ncpu) diff --git a/platforms/win/x64/external.sh b/platforms/win/x64/external.sh index 98b365b..7b9b8ba 100755 --- a/platforms/win/x64/external.sh +++ b/platforms/win/x64/external.sh @@ -3,10 +3,10 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd +LIBZEDMD_SHA=984ac9b14824d3924455c64f36c512e5b35852b7 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f -LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c +LIBPUPDMD_SHA=c640ea2cec94097e8baefee9dab39266970e4405 LIBFRAMEUTIL_SHA=d9bde3069786f1a33d2021afe19566d812e873f5 echo "Building libraries..." diff --git a/platforms/win/x86/external.sh b/platforms/win/x86/external.sh index 368ef89..a230064 100755 --- a/platforms/win/x86/external.sh +++ b/platforms/win/x86/external.sh @@ -3,10 +3,10 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=62ac355f1ab34b6a3520c6907eecc80a85fe04fd +LIBZEDMD_SHA=984ac9b14824d3924455c64f36c512e5b35852b7 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f -LIBPUPDMD_SHA=8dedc8c81ded2f6b8ca4614752d395aae0332c6c +LIBPUPDMD_SHA=c640ea2cec94097e8baefee9dab39266970e4405 LIBFRAMEUTIL_SHA=d9bde3069786f1a33d2021afe19566d812e873f5 echo "Building libraries..."