Fix AMD ALPR_OCR and custom model
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "ANSMatRegistry.h"
|
||||
#include "ANSGpuFrameOps.h"
|
||||
#include "GpuNV12SlotPool.h"
|
||||
#include "av_frame_ptr.h" // ansmedia::AvFramePtr — RAII for AVFrame*
|
||||
#include "ANSLicense.h" // ANS_DBG macro
|
||||
#include "ANSCVVendorGate.h" // anscv_vendor_gate::IsNvidiaGpuAvailable()
|
||||
#include <memory>
|
||||
@@ -1175,7 +1176,12 @@ extern "C" __declspec(dllexport) int GetRTSPCVImage(
|
||||
(void*)*image, gpuIdx, (int)inFlightGuardHeld);
|
||||
|
||||
if (inFlightGuardHeld) {
|
||||
AVFrame* cudaHW = (*Handle)->GetCudaHWFrame();
|
||||
// AvFramePtr wraps each clone obtained from the player so it
|
||||
// auto-frees on every return path before the .release() handoff
|
||||
// to gpu_frame_attach[_cuda]. This closes the leak window if
|
||||
// any future early-return / exception slips between the clone
|
||||
// call and the attach call.
|
||||
ansmedia::AvFramePtr cudaHW{ (*Handle)->GetCudaHWFrame() };
|
||||
if (cudaHW) {
|
||||
RTSP_DBG("[GetRTSPCVImage] cudaHW: %dx%d data[0]=%p data[1]=%p",
|
||||
cudaHW->width, cudaHW->height,
|
||||
@@ -1186,13 +1192,20 @@ extern "C" __declspec(dllexport) int GetRTSPCVImage(
|
||||
gpuIdx, cudaHW->width, cudaHW->height);
|
||||
|
||||
// Only fetch CPU NV12 if pool slot unavailable (cross-GPU fallback).
|
||||
AVFrame* cpuNV12 = slot ? nullptr : (*Handle)->GetNV12Frame();
|
||||
gpu_frame_attach_cuda(*image, cudaHW, gpuIdx, timeStamp, cpuNV12, slot);
|
||||
ansmedia::AvFramePtr cpuNV12{ slot ? nullptr : (*Handle)->GetNV12Frame() };
|
||||
ANS_DBG("MEDIA_AvPtr",
|
||||
"ANSRTSP attach_cuda cudaHW=%p cpuNV12=%p slot=%p gpuIdx=%d",
|
||||
(void*)cudaHW.get(), (void*)cpuNV12.get(), (void*)slot, gpuIdx);
|
||||
gpu_frame_attach_cuda(*image, cudaHW.release(), gpuIdx, timeStamp,
|
||||
cpuNV12.release(), slot);
|
||||
} else {
|
||||
// HW decode not active — try CPU NV12
|
||||
AVFrame* nv12 = (*Handle)->GetNV12Frame();
|
||||
ansmedia::AvFramePtr nv12{ (*Handle)->GetNV12Frame() };
|
||||
if (nv12) {
|
||||
gpu_frame_attach(*image, nv12, gpuIdx, timeStamp);
|
||||
ANS_DBG("MEDIA_AvPtr",
|
||||
"ANSRTSP attach nv12=%p gpuIdx=%d",
|
||||
(void*)nv12.get(), gpuIdx);
|
||||
gpu_frame_attach(*image, nv12.release(), gpuIdx, timeStamp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user