diff --git a/modules/ANSCV/ANSRTSP.cpp b/modules/ANSCV/ANSRTSP.cpp index 09e4851..20f3204 100644 --- a/modules/ANSCV/ANSRTSP.cpp +++ b/modules/ANSCV/ANSRTSP.cpp @@ -1063,11 +1063,15 @@ extern "C" __declspec(dllexport) int GetRTSPCVImage( RTSP_DBG("[GetRTSPCVImage] cudaHW: %dx%d data[0]=%p data[1]=%p", cudaHW->width, cudaHW->height, (void*)cudaHW->data[0], (void*)cudaHW->data[1]); - AVFrame* cpuNV12 = (*Handle)->GetNV12Frame(); // Acquire a slot from the global pool — survives camera Destroy. GpuNV12Slot* slot = GpuNV12SlotPool::instance().acquire( gpuIdx, cudaHW->width, cudaHW->height); + + // Only fetch CPU NV12 if pool slot unavailable (cross-GPU fallback). + // When slot is valid, the D2D copy goes GPU→GPU and CPU NV12 is never used. + // Skipping av_frame_clone + av_frame_free saves ~0.1ms per frame. + AVFrame* cpuNV12 = slot ? nullptr : (*Handle)->GetNV12Frame(); gpu_frame_attach_cuda(*image, cudaHW, gpuIdx, timeStamp, cpuNV12, slot); } else { // HW decode not active — try CPU NV12