Fix AMD ALPR_OCR and custom model
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "ANSMatRegistry.h"
|
||||
#include "ANSGpuFrameRegistry.h"
|
||||
#include "ANSGpuFrameOps.h" // gpu_frame_attach, gpu_frame_attach_cuda
|
||||
#include "av_frame_ptr.h" // ansmedia::AvFramePtr — RAII for AVFrame*
|
||||
#include <memory>
|
||||
#include <libswscale/swscale.h>
|
||||
#include <libavutil/imgutils.h>
|
||||
@@ -1010,17 +1011,27 @@ extern "C" __declspec(dllexport) int GetVideoPlayerCVImage(
|
||||
// When using cv::VideoCapture fallback, attach BGR clone (pixFmt=1000).
|
||||
if ((*Handle)->_hwDecodeActive && (*Handle)->_hwPlayer) {
|
||||
// --- HW decode: NV12/CUDA attachment (same pattern as ANSRTSP.cpp:847-862) ---
|
||||
// AvFramePtr wraps each clone so it auto-frees on any return path
|
||||
// before the .release() handoff to gpu_frame_attach[_cuda]. This
|
||||
// makes leak-by-omission impossible if an exception or early return
|
||||
// is added between the clone and the attach call.
|
||||
int gpuIdx = (*Handle)->_hwPlayer->getHWDecodingGpuIndex();
|
||||
AVFrame* cudaHW = (*Handle)->_hwPlayer->getCudaHWFrame();
|
||||
ansmedia::AvFramePtr cudaHW{ (*Handle)->_hwPlayer->getCudaHWFrame() };
|
||||
if (cudaHW) {
|
||||
// CUDA zero-copy: frame data[0]/data[1] are CUDA device pointers.
|
||||
// Also attach CPU NV12 as fallback for cross-GPU inference.
|
||||
AVFrame* cpuNV12 = (*Handle)->_hwPlayer->getNV12Frame();
|
||||
gpu_frame_attach_cuda(*image, cudaHW, gpuIdx, timeStamp, cpuNV12);
|
||||
ansmedia::AvFramePtr cpuNV12{ (*Handle)->_hwPlayer->getNV12Frame() };
|
||||
ANS_DBG("MEDIA_AvPtr",
|
||||
"ANSVideoPlayer attach_cuda cudaHW=%p cpuNV12=%p gpuIdx=%d",
|
||||
(void*)cudaHW.get(), (void*)cpuNV12.get(), gpuIdx);
|
||||
gpu_frame_attach_cuda(*image, cudaHW.release(), gpuIdx, timeStamp, cpuNV12.release());
|
||||
} else {
|
||||
AVFrame* nv12 = (*Handle)->_hwPlayer->getNV12Frame();
|
||||
ansmedia::AvFramePtr nv12{ (*Handle)->_hwPlayer->getNV12Frame() };
|
||||
if (nv12) {
|
||||
gpu_frame_attach(*image, nv12, gpuIdx, timeStamp);
|
||||
ANS_DBG("MEDIA_AvPtr",
|
||||
"ANSVideoPlayer attach nv12=%p gpuIdx=%d",
|
||||
(void*)nv12.get(), gpuIdx);
|
||||
gpu_frame_attach(*image, nv12.release(), gpuIdx, timeStamp);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user