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

@@ -883,12 +883,11 @@ int RSTPTestCVClient() {
while (true) {
index++;
std::cout << "Index=" << index << std::endl;
if ((index == 200) || (index == 800) || (index == 1200)) { StopRTSP(&rtspClient); }
if ((index == 400) || (index == 1000) || (index == 1500)) { StartRTSP(&rtspClient); }
if ((index == 1800) || (index == 2200) || (index == 2500)) { StartRTSP(&rtspClient); }
if ((index == 2000) || (index == 2300) || (index == 2700)) { StartRTSP(&rtspClient); }
if (index > 20000) break;
//if ((index == 200) || (index == 800) || (index == 1200)) { StopRTSP(&rtspClient); }
//if ((index == 400) || (index == 1000) || (index == 1500)) { StartRTSP(&rtspClient); }
//if ((index == 1800) || (index == 2200) || (index == 2500)) { StartRTSP(&rtspClient); }
//if ((index == 2000) || (index == 2300) || (index == 2700)) { StartRTSP(&rtspClient); }
//if (index > 20000) break;
auto start = std::chrono::system_clock::now();
cv::Mat* image = nullptr; // ✅ Use a pointer to hold the allocated image
GetRTSPCVImage(&rtspClient, width, height, pts,&image);
@@ -1485,12 +1484,12 @@ int main()
//OpenCVFunctionTest();
GenerateVideo();
//GenerateVideo();
//VideoTestClient();
// TestGetImage();
//PureOpenCV();
// RSTPTestClient();
//RSTPTestCVClient();
RSTPTestCVClient();
//TestCreateImageFromJpegStringFile();
//TestCreateImageFromFile();
//for (int i = 0; i < 100; i++) {