From 1dc5a9d7982f91b472d2e93da0a3b4ebe25bf08e Mon Sep 17 00:00:00 2001 From: Rajy Rawther Date: Fri, 8 Dec 2023 14:29:00 -0800 Subject: [PATCH] added release of copied buffers in host and hip (#126) * added release of copied buffers in host and hip * address review comments * addressed review comment --- utils/rocvideodecode/roc_video_dec.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/utils/rocvideodecode/roc_video_dec.cpp b/utils/rocvideodecode/roc_video_dec.cpp index 28404d6ba8..fd0fc17c90 100644 --- a/utils/rocvideodecode/roc_video_dec.cpp +++ b/utils/rocvideodecode/roc_video_dec.cpp @@ -72,6 +72,22 @@ RocVideoDecoder::~RocVideoDecoder() { roc_decoder_ = nullptr; } + std::lock_guard lock(mtx_vp_frame_); + if (out_mem_type_ != OUT_SURFACE_MEM_DEV_INTERNAL) { + for (auto &p_frame : vp_frames_) { + if (p_frame.frame_ptr) { + if (out_mem_type_ == OUT_SURFACE_MEM_DEV_COPIED) { + hipError_t hip_status = hipFree(p_frame.frame_ptr); + if (hip_status != hipSuccess) { + std::cout << "ERROR: hipFree failed! (" << hip_status << ")" << std::endl; + } + } + else + delete[] (p_frame.frame_ptr); + p_frame.frame_ptr = nullptr; + } + } + } if (hip_stream_) { hipError_t hip_status = hipSuccess; hip_status = hipStreamDestroy(hip_stream_);