From bbd980f23f235e12a7b9bd497dc29ff0ffc74a5d Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Mon, 14 Apr 2025 16:42:13 +0200 Subject: [PATCH 1/9] add config option to only dump not colorized frames --- include/DMDUtil/Config.h | 3 +++ src/Config.cpp | 1 + src/DMD.cpp | 22 +++++++++++++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/include/DMDUtil/Config.h b/include/DMDUtil/Config.h index 7fbc9d62..6cc3aae1 100644 --- a/include/DMDUtil/Config.h +++ b/include/DMDUtil/Config.h @@ -51,6 +51,8 @@ class DMDUTILAPI Config void SetMaximumUnknownFramesToSkip(int framesToSkip) { m_framesToSkip = framesToSkip; } int GetIgnoreUnknownFramesTimeout() { return m_framesTimeout; } int GetMaximumUnknownFramesToSkip() { return m_framesToSkip; } + bool IsDumpNotColorizedFrames() const { return m_dumpNotColorizedFrames; } + void SetDumpNotColorizedFrames(bool dumpNotColorizedFrames) { m_dumpNotColorizedFrames = dumpNotColorizedFrames; } bool IsZeDMD() const { return m_zedmd; } void SetZeDMD(bool zedmd) { m_zedmd = zedmd; } const char* GetZeDMDDevice() const { return m_zedmdDevice.c_str(); } @@ -96,6 +98,7 @@ class DMDUTILAPI Config bool m_pupExactColorMatch; int m_framesTimeout; int m_framesToSkip; + bool m_dumpNotColorizedFrames; bool m_zedmd; std::string m_zedmdDevice; bool m_zedmdDebug; diff --git a/src/Config.cpp b/src/Config.cpp index 94b9cb65..4dcb2449 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -23,6 +23,7 @@ Config::Config() m_pupExactColorMatch = true; m_framesTimeout = 0; m_framesToSkip = 0; + m_dumpNotColorizedFrames = false; m_zedmd = true; m_zedmdDevice.clear(); m_zedmdDebug = false; diff --git a/src/DMD.cpp b/src/DMD.cpp index 0518dbd9..b97e8d69 100644 --- a/src/DMD.cpp +++ b/src/DMD.cpp @@ -236,9 +236,21 @@ void DMD::SetAltColorPath(const char* path) { strcpy(m_altColorPath, path ? path void DMD::SetPUPVideosPath(const char* path) { strcpy(m_pupVideosPath, path ? path : ""); } -void DMD::DumpDMDTxt() { m_pDumpDMDTxtThread = new std::thread(&DMD::DumpDMDTxtThread, this); } +void DMD::DumpDMDTxt() +{ + if (!m_pDumpDMDTxtThread) + { + m_pDumpDMDTxtThread = new std::thread(&DMD::DumpDMDTxtThread, this); + } +} -void DMD::DumpDMDRaw() { m_pDumpDMDRawThread = new std::thread(&DMD::DumpDMDRawThread, this); } +void DMD::DumpDMDRaw() +{ + if (m_pDumpDMDRawThread) + { + m_pDumpDMDRawThread = new std::thread(&DMD::DumpDMDRawThread, this); + } +} LevelDMD* DMD::CreateLevelDMD(uint16_t width, uint16_t height, bool sam) { @@ -1427,6 +1439,9 @@ void DMD::DumpDMDTxtThread() m_dmdFrameReady.load(std::memory_order_acquire); m_stopFlag.load(std::memory_order_acquire); + Config* const pConfig = Config::GetInstance(); + bool dumpNotColorizedFrames = pConfig->IsDumpNotColorizedFrames(); + while (true) { std::shared_lock sl(m_dmdSharedMutex); @@ -1507,7 +1522,8 @@ void DMD::DumpDMDTxtThread() if (f) { - if (passed[0] > 0) + if (passed[0] > 0 && + (!dumpNotColorizedFrames || (m_pSerum && (!IsSerumMode(m_pUpdateBufferQueue[bufferPosition]->mode))))) { fprintf(f, "0x%08x\r\n", passed[0]); for (int y = 0; y < m_pUpdateBufferQueue[bufferPosition]->height; y++) From 257a1dd5d2ab7e30cb2a08c6972824af0488bd8e Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Mon, 14 Apr 2025 17:54:33 +0200 Subject: [PATCH 2/9] avoid duplicates in non colorized frames dump --- platforms/android/arm64-v8a/external.sh | 1 + platforms/ios-simulator/arm64/external.sh | 1 + platforms/ios/arm64/external.sh | 1 + platforms/linux/aarch64/external.sh | 1 + platforms/linux/x64/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 + src/DMD.cpp | 31 +++++++++++++++++++---- 11 files changed, 36 insertions(+), 5 deletions(-) diff --git a/platforms/android/arm64-v8a/external.sh b/platforms/android/arm64-v8a/external.sh index 69b64d72..85cf3463 100755 --- a/platforms/android/arm64-v8a/external.sh +++ b/platforms/android/arm64-v8a/external.sh @@ -40,6 +40,7 @@ cmake \ -B build cmake --build build -- -j${NUM_PROCS} cp src/ZeDMD.h ../../third-party/include/ +cp -r third-party/include/komihash ../../third-party/include/ cp -r third-party/include/sockpp ../../third-party/include/ cp third-party/include/FrameUtil.h ../../third-party/include/ cp third-party/runtime-libs/android/arm64-v8a/libsockpp.so ../../third-party/runtime-libs/android/arm64-v8a/ diff --git a/platforms/ios-simulator/arm64/external.sh b/platforms/ios-simulator/arm64/external.sh index e08849c8..f10ca998 100755 --- a/platforms/ios-simulator/arm64/external.sh +++ b/platforms/ios-simulator/arm64/external.sh @@ -34,6 +34,7 @@ cmake \ -B build cmake --build build -- -j${NUM_PROCS} cp src/ZeDMD.h ../../third-party/include/ +cp -r third-party/include/komihash ../../third-party/include/ cp -r third-party/include/sockpp ../../third-party/include/ cp third-party/include/FrameUtil.h ../../third-party/include/ cp -a third-party/build-libs/ios-simulator/arm64/libsockpp.a ../../third-party/build-libs/ios-simulator/arm64/ diff --git a/platforms/ios/arm64/external.sh b/platforms/ios/arm64/external.sh index 0db95851..b150381e 100755 --- a/platforms/ios/arm64/external.sh +++ b/platforms/ios/arm64/external.sh @@ -34,6 +34,7 @@ cmake \ -B build cmake --build build -- -j${NUM_PROCS} cp src/ZeDMD.h ../../third-party/include/ +cp -r third-party/include/komihash ../../third-party/include/ cp -r third-party/include/sockpp ../../third-party/include/ cp third-party/include/FrameUtil.h ../../third-party/include/ cp -a third-party/build-libs/ios/arm64/libsockpp.a ../../third-party/build-libs/ios/arm64/ diff --git a/platforms/linux/aarch64/external.sh b/platforms/linux/aarch64/external.sh index c9f1a478..26175873 100755 --- a/platforms/linux/aarch64/external.sh +++ b/platforms/linux/aarch64/external.sh @@ -36,6 +36,7 @@ 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/cargs.h ../../third-party/include/ +cp -r third-party/include/komihash ../../third-party/include/ cp -r third-party/include/sockpp ../../third-party/include/ cp third-party/include/FrameUtil.h ../../third-party/include/ cp third-party/runtime-libs/linux/aarch64/libcargs.so ../../third-party/runtime-libs/linux/aarch64/ diff --git a/platforms/linux/x64/external.sh b/platforms/linux/x64/external.sh index 09d9ea90..d328897b 100755 --- a/platforms/linux/x64/external.sh +++ b/platforms/linux/x64/external.sh @@ -36,6 +36,7 @@ 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/cargs.h ../../third-party/include/ +cp -r third-party/include/komihash ../../third-party/include/ cp -r third-party/include/sockpp ../../third-party/include/ cp third-party/include/FrameUtil.h ../../third-party/include/ cp third-party/runtime-libs/linux/x64/libcargs.so ../../third-party/runtime-libs/linux/x64/ diff --git a/platforms/macos/arm64/external.sh b/platforms/macos/arm64/external.sh index 54dbcdc1..4a3c75a5 100755 --- a/platforms/macos/arm64/external.sh +++ b/platforms/macos/arm64/external.sh @@ -36,6 +36,7 @@ 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/cargs.h ../../third-party/include/ +cp -r third-party/include/komihash ../../third-party/include/ cp -r third-party/include/sockpp ../../third-party/include/ cp third-party/include/FrameUtil.h ../../third-party/include/ cp third-party/runtime-libs/macos/arm64/libcargs.dylib ../../third-party/runtime-libs/macos/arm64/ diff --git a/platforms/macos/x64/external.sh b/platforms/macos/x64/external.sh index 7bee8364..b675e02a 100755 --- a/platforms/macos/x64/external.sh +++ b/platforms/macos/x64/external.sh @@ -36,6 +36,7 @@ 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/cargs.h ../../third-party/include/ +cp -r third-party/include/komihash ../../third-party/include/ cp -r third-party/include/sockpp ../../third-party/include/ cp third-party/include/FrameUtil.h ../../third-party/include/ cp third-party/runtime-libs/macos/x64/libcargs.dylib ../../third-party/runtime-libs/macos/x64/ diff --git a/platforms/tvos/arm64/external.sh b/platforms/tvos/arm64/external.sh index 1c0de920..7e3fd77f 100755 --- a/platforms/tvos/arm64/external.sh +++ b/platforms/tvos/arm64/external.sh @@ -34,6 +34,7 @@ cmake \ -B build cmake --build build -- -j${NUM_PROCS} cp src/ZeDMD.h ../../third-party/include/ +cp -r third-party/include/komihash ../../third-party/include/ cp -r third-party/include/sockpp ../../third-party/include/ cp third-party/include/FrameUtil.h ../../third-party/include/ cp -a third-party/build-libs/tvos/arm64/libsockpp.a ../../third-party/build-libs/tvos/arm64/ diff --git a/platforms/win/x64/external.sh b/platforms/win/x64/external.sh index 57a3155f..03ff5974 100755 --- a/platforms/win/x64/external.sh +++ b/platforms/win/x64/external.sh @@ -33,6 +33,7 @@ cmake \ cmake --build build --config ${BUILD_TYPE} cp src/ZeDMD.h ../../third-party/include/ cp third-party/include/cargs.h ../../third-party/include/ +cp -r third-party/include/komihash ../../third-party/include/ cp -r third-party/include/sockpp ../../third-party/include/ cp third-party/include/FrameUtil.h ../../third-party/include/ cp third-party/include/libserialport.h ../../third-party/include/ diff --git a/platforms/win/x86/external.sh b/platforms/win/x86/external.sh index a8ffd63b..877d417c 100755 --- a/platforms/win/x86/external.sh +++ b/platforms/win/x86/external.sh @@ -35,6 +35,7 @@ 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/cargs.h ../../third-party/include/ +cp -r third-party/include/komihash ../../third-party/include/ cp -r third-party/include/sockpp ../../third-party/include/ cp third-party/include/FrameUtil.h ../../third-party/include/ cp third-party/build-libs/win/x86/cargs.lib ../../third-party/build-libs/win/x86/ diff --git a/src/DMD.cpp b/src/DMD.cpp index b97e8d69..c536fcb8 100644 --- a/src/DMD.cpp +++ b/src/DMD.cpp @@ -14,11 +14,13 @@ #include #include #include +#include #include "AlphaNumeric.h" #include "FrameUtil.h" #include "Logger.h" #include "ZeDMD.h" +#include "komihash.h" #include "pupdmd.h" #include "serum-decode.h" #include "serum.h" @@ -1435,6 +1437,7 @@ void DMD::DumpDMDTxtThread() uint32_t passed[3] = {0}; std::chrono::steady_clock::time_point start; FILE* f = nullptr; + std::unordered_set seenHashes; m_dmdFrameReady.load(std::memory_order_acquire); m_stopFlag.load(std::memory_order_acquire); @@ -1525,16 +1528,34 @@ void DMD::DumpDMDTxtThread() if (passed[0] > 0 && (!dumpNotColorizedFrames || (m_pSerum && (!IsSerumMode(m_pUpdateBufferQueue[bufferPosition]->mode))))) { - fprintf(f, "0x%08x\r\n", passed[0]); - for (int y = 0; y < m_pUpdateBufferQueue[bufferPosition]->height; y++) + bool dump = true; + + if (dumpNotColorizedFrames) + { + uint64_t hash = komihash(renderBuffer[0], length, 0); + if (seenHashes.find(hash) == seenHashes.end()) + { + seenHashes.insert(hash); + } + else + { + dump = false; + } + } + + if (dump) { - for (int x = 0; x < m_pUpdateBufferQueue[bufferPosition]->width; x++) + fprintf(f, "0x%08x\r\n", passed[0]); + for (int y = 0; y < m_pUpdateBufferQueue[bufferPosition]->height; y++) { - fprintf(f, "%x", renderBuffer[0][y * m_pUpdateBufferQueue[bufferPosition]->width + x]); + for (int x = 0; x < m_pUpdateBufferQueue[bufferPosition]->width; x++) + { + fprintf(f, "%x", renderBuffer[0][y * m_pUpdateBufferQueue[bufferPosition]->width + x]); + } + fprintf(f, "\r\n"); } fprintf(f, "\r\n"); } - fprintf(f, "\r\n"); } } memcpy(renderBuffer[0], renderBuffer[1], length); From b89a40de412df8dc5e9444e2f0418c6cf8889b6f Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Mon, 14 Apr 2025 18:30:44 +0200 Subject: [PATCH 3/9] fixed komihash include --- src/DMD.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DMD.cpp b/src/DMD.cpp index c536fcb8..8a54bd6b 100644 --- a/src/DMD.cpp +++ b/src/DMD.cpp @@ -20,7 +20,7 @@ #include "FrameUtil.h" #include "Logger.h" #include "ZeDMD.h" -#include "komihash.h" +#include "komihash/komihash.h" #include "pupdmd.h" #include "serum-decode.h" #include "serum.h" From 6749c2535cf1bdb5de0d4631cad89e9760a4a22a Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Mon, 14 Apr 2025 19:12:12 +0200 Subject: [PATCH 4/9] fixed dump of not colorized frames --- include/DMDUtil/DMD.h | 1 + src/DMD.cpp | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/include/DMDUtil/DMD.h b/include/DMDUtil/DMD.h index 66ea1f95..a75d7d92 100644 --- a/include/DMDUtil/DMD.h +++ b/include/DMDUtil/DMD.h @@ -89,6 +89,7 @@ class DMDUTILAPI DMD SerumV2_32_64, // int 7 SerumV2_64, // int 8 SerumV2_64_32, // int 9 + NotColorized, // int 10 }; bool IsSerumMode(Mode mode) diff --git a/src/DMD.cpp b/src/DMD.cpp index 8a54bd6b..a7d9f447 100644 --- a/src/DMD.cpp +++ b/src/DMD.cpp @@ -781,6 +781,9 @@ void DMD::SerumThread() m_dmdFrameReady.load(std::memory_order_acquire); m_stopFlag.load(std::memory_order_acquire); + Config* const pConfig = Config::GetInstance(); + bool dumpNotColorizedFrames = pConfig->IsDumpNotColorizedFrames(); + while (true) { std::shared_lock sl(m_dmdSharedMutex); @@ -864,6 +867,19 @@ void DMD::SerumThread() prevTriggerId = m_pSerum->triggerID; } } + else if (dumpNotColorizedFrames) + { + auto noSerumUpdate = std::make_shared(); + noSerumUpdate->mode = Mode::NotColorized; + noSerumUpdate->depth = m_pUpdateBufferQueue[bufferPosition]->depth; + noSerumUpdate->width = m_pUpdateBufferQueue[bufferPosition]->width; + noSerumUpdate->height = m_pUpdateBufferQueue[bufferPosition]->height; + memcpy( + noSerumUpdate->data, m_pUpdateBufferQueue[bufferPosition]->data, + (size_t)m_pUpdateBufferQueue[bufferPosition]->width * m_pUpdateBufferQueue[bufferPosition]->height); + + QueueUpdate(noSerumUpdate, false); + } } } } @@ -1468,8 +1484,9 @@ void DMD::DumpDMDTxtThread() // Don't use GetNextBufferPosition() here, we need all frames! if (++bufferPosition >= DMDUTIL_FRAME_BUFFER_SIZE) bufferPosition = 0; - if (m_pUpdateBufferQueue[bufferPosition]->depth <= 4 && - m_pUpdateBufferQueue[bufferPosition]->mode == Mode::Data && m_pUpdateBufferQueue[bufferPosition]->hasData) + if (m_pUpdateBufferQueue[bufferPosition]->depth <= 4 && m_pUpdateBufferQueue[bufferPosition]->hasData && + (m_pUpdateBufferQueue[bufferPosition]->mode == Mode::Data || + (m_pUpdateBufferQueue[bufferPosition]->mode == Mode::NotColorized && dumpNotColorizedFrames))) { bool update = false; if (strcmp(m_romName, name) != 0) @@ -1526,7 +1543,7 @@ void DMD::DumpDMDTxtThread() if (f) { if (passed[0] > 0 && - (!dumpNotColorizedFrames || (m_pSerum && (!IsSerumMode(m_pUpdateBufferQueue[bufferPosition]->mode))))) + (!dumpNotColorizedFrames || m_pUpdateBufferQueue[bufferPosition]->mode == Mode::NotColorized)) { bool dump = true; From be141d4e611101451984ed720ba1b05be7653300 Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Mon, 14 Apr 2025 20:50:53 +0200 Subject: [PATCH 5/9] added data flags --- src/DMD.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/DMD.cpp b/src/DMD.cpp index a7d9f447..64cbbcfe 100644 --- a/src/DMD.cpp +++ b/src/DMD.cpp @@ -874,6 +874,9 @@ void DMD::SerumThread() noSerumUpdate->depth = m_pUpdateBufferQueue[bufferPosition]->depth; noSerumUpdate->width = m_pUpdateBufferQueue[bufferPosition]->width; noSerumUpdate->height = m_pUpdateBufferQueue[bufferPosition]->height; + noSerumUpdate->hasData = true; + noSerumUpdate->hasSegData = false; + noSerumUpdate->hasSegData2 = false; memcpy( noSerumUpdate->data, m_pUpdateBufferQueue[bufferPosition]->data, (size_t)m_pUpdateBufferQueue[bufferPosition]->width * m_pUpdateBufferQueue[bufferPosition]->height); From 8ddd9e932641c451998dcf351fcdd239cacc47af Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Mon, 14 Apr 2025 21:27:13 +0200 Subject: [PATCH 6/9] added debug output --- src/DMD.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/DMD.cpp b/src/DMD.cpp index 64cbbcfe..b363760a 100644 --- a/src/DMD.cpp +++ b/src/DMD.cpp @@ -869,6 +869,8 @@ void DMD::SerumThread() } else if (dumpNotColorizedFrames) { + Log(DMDUtil_LogLevel_DEBUG, "Serum: unidentified frame detected"); + auto noSerumUpdate = std::make_shared(); noSerumUpdate->mode = Mode::NotColorized; noSerumUpdate->depth = m_pUpdateBufferQueue[bufferPosition]->depth; From a76a67ca061f0b5105f6debc0e3b99248740bbca Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Tue, 15 Apr 2025 11:02:59 +0200 Subject: [PATCH 7/9] improved dump conditions --- include/DMDUtil/DMD.h | 22 +++++++++++----------- src/DMD.cpp | 7 ++++--- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/include/DMDUtil/DMD.h b/include/DMDUtil/DMD.h index a75d7d92..a6a1d567 100644 --- a/include/DMDUtil/DMD.h +++ b/include/DMDUtil/DMD.h @@ -79,17 +79,17 @@ class DMDUTILAPI DMD enum class Mode { - Unknown, // int 0 - Data, // int 1 - RGB24, // int 2, RGB888 - RGB16, // int 3, RGB565 - AlphaNumeric, // int 4 - SerumV1, // int 5 - SerumV2_32, // int 6 - SerumV2_32_64, // int 7 - SerumV2_64, // int 8 - SerumV2_64_32, // int 9 - NotColorized, // int 10 + Unknown = 0, + Data = 1, + RGB24 = 2, // RGB888 + RGB16 = 3, // RGB565 + AlphaNumeric = 4, + SerumV1 = 5, + SerumV2_32 = 6, + SerumV2_32_64 = 7, + SerumV2_64 = 8, + SerumV2_64_32 = 9, + NotColorized = 10, }; bool IsSerumMode(Mode mode) diff --git a/src/DMD.cpp b/src/DMD.cpp index b363760a..f17b5f92 100644 --- a/src/DMD.cpp +++ b/src/DMD.cpp @@ -1490,9 +1490,11 @@ void DMD::DumpDMDTxtThread() if (++bufferPosition >= DMDUTIL_FRAME_BUFFER_SIZE) bufferPosition = 0; if (m_pUpdateBufferQueue[bufferPosition]->depth <= 4 && m_pUpdateBufferQueue[bufferPosition]->hasData && - (m_pUpdateBufferQueue[bufferPosition]->mode == Mode::Data || + ((m_pUpdateBufferQueue[bufferPosition]->mode == Mode::Data && !dumpNotColorizedFrames) || (m_pUpdateBufferQueue[bufferPosition]->mode == Mode::NotColorized && dumpNotColorizedFrames))) { + Log(DMDUtil_LogLevel_DEBUG, "DumpDMDTxt: hanlde frame, mode %d", m_pUpdateBufferQueue[bufferPosition]->mode); + bool update = false; if (strcmp(m_romName, name) != 0) { @@ -1547,8 +1549,7 @@ void DMD::DumpDMDTxtThread() if (f) { - if (passed[0] > 0 && - (!dumpNotColorizedFrames || m_pUpdateBufferQueue[bufferPosition]->mode == Mode::NotColorized)) + if (passed[0] > 0) { bool dump = true; From 2c41495cbdd4519de7456b58103f7808cef0eec9 Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Tue, 15 Apr 2025 11:41:17 +0200 Subject: [PATCH 8/9] moder debug logging --- src/DMD.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/DMD.cpp b/src/DMD.cpp index f17b5f92..ed53715b 100644 --- a/src/DMD.cpp +++ b/src/DMD.cpp @@ -1493,7 +1493,7 @@ void DMD::DumpDMDTxtThread() ((m_pUpdateBufferQueue[bufferPosition]->mode == Mode::Data && !dumpNotColorizedFrames) || (m_pUpdateBufferQueue[bufferPosition]->mode == Mode::NotColorized && dumpNotColorizedFrames))) { - Log(DMDUtil_LogLevel_DEBUG, "DumpDMDTxt: hanlde frame, mode %d", m_pUpdateBufferQueue[bufferPosition]->mode); + Log(DMDUtil_LogLevel_DEBUG, "DumpDMDTxt: handle frame, mode %d", m_pUpdateBufferQueue[bufferPosition]->mode); bool update = false; if (strcmp(m_romName, name) != 0) @@ -1521,6 +1521,7 @@ void DMD::DumpDMDTxtThread() if (name[0] != '\0') { int length = (int)m_pUpdateBufferQueue[bufferPosition]->width * m_pUpdateBufferQueue[bufferPosition]->height; + Log(DMDUtil_LogLevel_DEBUG, "DumpDMDTxt: handle frame, length %d", length); if (update || (memcmp(renderBuffer[1], m_pUpdateBufferQueue[bufferPosition]->data, length) != 0)) { passed[2] = (uint32_t)(std::chrono::duration_cast( @@ -1540,6 +1541,8 @@ void DMD::DumpDMDTxtThread() } if (i == length) { + Log(DMDUtil_LogLevel_DEBUG, "DumpDMDTxt: skip transitional frame"); + // renderBuffer[1] is a transitional frame, delete it. memcpy(renderBuffer[1], renderBuffer[2], length); passed[1] += passed[2]; @@ -1562,6 +1565,7 @@ void DMD::DumpDMDTxtThread() } else { + Log(DMDUtil_LogLevel_DEBUG, "DumpDMDTxt: skip duplicate frame"); dump = false; } } From 223e5fc0ee6b011535393b3a91c608585167ddb9 Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Wed, 16 Apr 2025 10:31:53 +0200 Subject: [PATCH 9/9] filtering transitional frames should be optional --- include/DMDUtil/Config.h | 6 ++++++ src/Config.cpp | 1 + src/DMD.cpp | 6 ++---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/DMDUtil/Config.h b/include/DMDUtil/Config.h index 6cc3aae1..76cc1ee3 100644 --- a/include/DMDUtil/Config.h +++ b/include/DMDUtil/Config.h @@ -53,6 +53,11 @@ class DMDUTILAPI Config int GetMaximumUnknownFramesToSkip() { return m_framesToSkip; } bool IsDumpNotColorizedFrames() const { return m_dumpNotColorizedFrames; } void SetDumpNotColorizedFrames(bool dumpNotColorizedFrames) { m_dumpNotColorizedFrames = dumpNotColorizedFrames; } + bool IsFilterTransitionalFrames() const { return m_filterTransitionalFrames; } + void SetFilterTransitionalFrames(bool filterTransitionalFrames) + { + m_filterTransitionalFrames = filterTransitionalFrames; + } bool IsZeDMD() const { return m_zedmd; } void SetZeDMD(bool zedmd) { m_zedmd = zedmd; } const char* GetZeDMDDevice() const { return m_zedmdDevice.c_str(); } @@ -99,6 +104,7 @@ class DMDUTILAPI Config int m_framesTimeout; int m_framesToSkip; bool m_dumpNotColorizedFrames; + bool m_filterTransitionalFrames; bool m_zedmd; std::string m_zedmdDevice; bool m_zedmdDebug; diff --git a/src/Config.cpp b/src/Config.cpp index 4dcb2449..5c8c7955 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -24,6 +24,7 @@ Config::Config() m_framesTimeout = 0; m_framesToSkip = 0; m_dumpNotColorizedFrames = false; + m_filterTransitionalFrames = false; m_zedmd = true; m_zedmdDevice.clear(); m_zedmdDebug = false; diff --git a/src/DMD.cpp b/src/DMD.cpp index ed53715b..c1005385 100644 --- a/src/DMD.cpp +++ b/src/DMD.cpp @@ -1465,6 +1465,7 @@ void DMD::DumpDMDTxtThread() Config* const pConfig = Config::GetInstance(); bool dumpNotColorizedFrames = pConfig->IsDumpNotColorizedFrames(); + bool filterTransitionalFrames = pConfig->IsFilterTransitionalFrames(); while (true) { @@ -1493,8 +1494,6 @@ void DMD::DumpDMDTxtThread() ((m_pUpdateBufferQueue[bufferPosition]->mode == Mode::Data && !dumpNotColorizedFrames) || (m_pUpdateBufferQueue[bufferPosition]->mode == Mode::NotColorized && dumpNotColorizedFrames))) { - Log(DMDUtil_LogLevel_DEBUG, "DumpDMDTxt: handle frame, mode %d", m_pUpdateBufferQueue[bufferPosition]->mode); - bool update = false; if (strcmp(m_romName, name) != 0) { @@ -1521,7 +1520,6 @@ void DMD::DumpDMDTxtThread() if (name[0] != '\0') { int length = (int)m_pUpdateBufferQueue[bufferPosition]->width * m_pUpdateBufferQueue[bufferPosition]->height; - Log(DMDUtil_LogLevel_DEBUG, "DumpDMDTxt: handle frame, length %d", length); if (update || (memcmp(renderBuffer[1], m_pUpdateBufferQueue[bufferPosition]->data, length) != 0)) { passed[2] = (uint32_t)(std::chrono::duration_cast( @@ -1529,7 +1527,7 @@ void DMD::DumpDMDTxtThread() .count()); memcpy(renderBuffer[2], m_pUpdateBufferQueue[bufferPosition]->data, length); - if (m_pUpdateBufferQueue[bufferPosition]->depth == 2 && + if (filterTransitionalFrames && m_pUpdateBufferQueue[bufferPosition]->depth == 2 && (passed[2] - passed[1]) < DMDUTIL_MAX_TRANSITIONAL_FRAME_DURATION) { int i = 0;