Improve ANSCV with sotfware decoder:

Thread-local staging Mat (video_player.cpp:1400-1407) — single biggest win. Eliminates the 12 MB per-call malloc/free cycle.
Contiguous get_buffer2 allocator (video_decoder.cpp:35-102) — keeps the 3 bulk memcpys cache-friendly. Would also enable FAST/zero-copy for resolutions where visible_h % 64 == 0.
SW-decoder thread config (video_decoder.cpp:528-540) — thread_count=0, thread_type=FRAME|SLICE. FRAME is downgraded to SLICE-only by AV_CODEC_FLAG_LOW_DELAY, but decode throughput is sufficient for your input rate.
SetTargetFPS(100) delivery throttle (already there) — caps onVideoFrame post-decode work at 10 FPS. Keeps the caller path warm-cached.
Instrumentation — [MEDIA_DecInit] / [MEDIA_Convert] / [MEDIA_SWDec] / [MEDIA_Timing] / [MEDIA_JpegTiming] — always-on regression detector, zero cost when ANSCORE_DEBUGVIEW=OFF.
This commit is contained in:
2026-04-20 12:18:43 +10:00
parent adf32da2a2
commit 9f0a10a4c8
13 changed files with 431 additions and 201 deletions

View File

@@ -8,7 +8,7 @@
// Set to 0 for production builds to eliminate all debug output overhead.
// ============================================================================
#ifndef ANSCORE_DEBUGVIEW
#define ANSCORE_DEBUGVIEW 0 // 1 = enabled (debug), 0 = disabled (production)
#define ANSCORE_DEBUGVIEW 1 // 1 = enabled (debug), 0 = disabled (production)
#endif
// ANS_DBG: Debug logging macro for DebugView (OutputDebugStringA on Windows).
@@ -19,10 +19,24 @@
// conflicts. Instead, forward-declare OutputDebugStringA directly.
#if ANSCORE_DEBUGVIEW && defined(_WIN32)
extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char* lpOutputString);
// Emit to BOTH DebugView (OutputDebugStringA) AND stderr so console apps
// (ANSCV-UnitTest, ANSLPR-UnitTest, ANSUtilities_test, etc.) show the message
// without needing to attach DebugView. fputs + fflush keeps lines atomic even
// when multiple threads log concurrently.
#define ANS_DBG(tag, fmt, ...) do { \
char _ans_dbg_buf[1024]; \
snprintf(_ans_dbg_buf, sizeof(_ans_dbg_buf), "[" tag "] " fmt "\n", ##__VA_ARGS__); \
OutputDebugStringA(_ans_dbg_buf); \
fputs(_ans_dbg_buf, stderr); \
fflush(stderr); \
} while(0)
#elif ANSCORE_DEBUGVIEW
// Non-Windows: stderr only.
#define ANS_DBG(tag, fmt, ...) do { \
char _ans_dbg_buf[1024]; \
snprintf(_ans_dbg_buf, sizeof(_ans_dbg_buf), "[" tag "] " fmt "\n", ##__VA_ARGS__); \
fputs(_ans_dbg_buf, stderr); \
fflush(stderr); \
} while(0)
#else
#define ANS_DBG(tag, fmt, ...) ((void)0)