From c7a1f20703970383781fb9cd0a5ff076b85e2224 Mon Sep 17 00:00:00 2001 From: Hu Chunming <2657262686@qq.com> Date: Thu, 1 Aug 2024 11:13:10 +0800 Subject: [PATCH] 优化代码,防止可能的内存泄露 --- src/decoder/dvpp/DvppDecoder.cpp | 2 ++ src/decoder/dvpp/DvppStreamDecoder.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/decoder/dvpp/DvppDecoder.cpp b/src/decoder/dvpp/DvppDecoder.cpp index 4d76ee6..778ecb4 100644 --- a/src/decoder/dvpp/DvppDecoder.cpp +++ b/src/decoder/dvpp/DvppDecoder.cpp @@ -587,6 +587,8 @@ void DvppDecoder::read_thread() { if (m_bReal && m_DvppCacheCounter.load() > m_cache_gop){ // 解码器解码不过来。实时流在此处的处理会导致花屏,这是由于解码器性能问题导致,无法避免 // 实时流在这里处理是为了避免长时间不读取数据导致数据中断 + av_packet_free(&pkt); + pkt = nullptr; std::this_thread::sleep_for(std::chrono::milliseconds(10)); continue; } diff --git a/src/decoder/dvpp/DvppStreamDecoder.cpp b/src/decoder/dvpp/DvppStreamDecoder.cpp index 387c521..e88ba7e 100644 --- a/src/decoder/dvpp/DvppStreamDecoder.cpp +++ b/src/decoder/dvpp/DvppStreamDecoder.cpp @@ -500,7 +500,7 @@ int DvppStreamDecoder::SendData(int videoType, char* data, int len, int isKey, u #ifdef USE_VILLAGE //直接返回,不释放pkt,pkt在recoderManager释放 return 0; -#elif +#else ret = 0; #endif } -- libgit2 0.21.4