Fix AMD ALPR_OCR and custom model
This commit is contained in:
+29
-12
@@ -1,6 +1,7 @@
|
||||
#include "ANSRTMP.h"
|
||||
#include "ANSMatRegistry.h"
|
||||
#include "ANSGpuFrameOps.h"
|
||||
#include "av_frame_ptr.h" // ansmedia::AvFramePtr — RAII for AVFrame*
|
||||
#include "ANSCVVendorGate.h" // anscv_vendor_gate::IsNvidiaGpuAvailable()
|
||||
#include "ANSLicense.h" // ANS_DBG macro
|
||||
#include <memory>
|
||||
@@ -808,17 +809,25 @@ extern "C" __declspec(dllexport) int GetRTMPCVImage(ANSCENTER::ANSRTMPClient** H
|
||||
// Thread-safe Mat pointer swap (anscv_mat_replace has its own internal lock)
|
||||
anscv_mat_replace(image, std::move(img));
|
||||
|
||||
// NV12 GPU fast path (optional — disabled by default for stability)
|
||||
// NV12 GPU fast path (optional — disabled by default for stability).
|
||||
// AvFramePtr auto-frees clones if we don't reach the .release() handoff.
|
||||
if ((*Handle)->IsNV12FastPath()) {
|
||||
int gpuIdx = (*Handle)->GetHWDecodingGpuIndex();
|
||||
AVFrame* cudaHW = (*Handle)->GetCudaHWFrame();
|
||||
ansmedia::AvFramePtr cudaHW{ (*Handle)->GetCudaHWFrame() };
|
||||
if (cudaHW) {
|
||||
AVFrame* cpuNV12 = (*Handle)->GetNV12Frame();
|
||||
gpu_frame_attach_cuda(*image, cudaHW, gpuIdx, timeStamp, cpuNV12);
|
||||
ansmedia::AvFramePtr cpuNV12{ (*Handle)->GetNV12Frame() };
|
||||
ANS_DBG("MEDIA_AvPtr",
|
||||
"ANSRTMP V1 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)->GetNV12Frame();
|
||||
ansmedia::AvFramePtr nv12{ (*Handle)->GetNV12Frame() };
|
||||
if (nv12) {
|
||||
gpu_frame_attach(*image, nv12, gpuIdx, timeStamp);
|
||||
ANS_DBG("MEDIA_AvPtr",
|
||||
"ANSRTMP V1 attach nv12=%p gpuIdx=%d",
|
||||
(void*)nv12.get(), gpuIdx);
|
||||
gpu_frame_attach(*image, nv12.release(), gpuIdx, timeStamp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1053,16 +1062,24 @@ extern "C" __declspec(dllexport) int GetRTMPCVImage_V2(uint64_t handleVal, int&
|
||||
}
|
||||
anscv_mat_replace(image, std::move(img));
|
||||
|
||||
// Attach NV12 frame for GPU fast-path inference (side-table registry)
|
||||
// Attach NV12 frame for GPU fast-path inference (side-table registry).
|
||||
// AvFramePtr auto-frees clones if we don't reach the .release() handoff.
|
||||
int gpuIdx = h->GetHWDecodingGpuIndex();
|
||||
AVFrame* cudaHW = h->GetCudaHWFrame();
|
||||
ansmedia::AvFramePtr cudaHW{ h->GetCudaHWFrame() };
|
||||
if (cudaHW) {
|
||||
AVFrame* cpuNV12 = h->GetNV12Frame();
|
||||
gpu_frame_attach_cuda(*image, cudaHW, gpuIdx, timeStamp, cpuNV12);
|
||||
ansmedia::AvFramePtr cpuNV12{ h->GetNV12Frame() };
|
||||
ANS_DBG("MEDIA_AvPtr",
|
||||
"ANSRTMP V2 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 = h->GetNV12Frame();
|
||||
ansmedia::AvFramePtr nv12{ h->GetNV12Frame() };
|
||||
if (nv12) {
|
||||
gpu_frame_attach(*image, nv12, gpuIdx, timeStamp);
|
||||
ANS_DBG("MEDIA_AvPtr",
|
||||
"ANSRTMP V2 attach nv12=%p gpuIdx=%d",
|
||||
(void*)nv12.get(), gpuIdx);
|
||||
gpu_frame_attach(*image, nv12.release(), gpuIdx, timeStamp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user