From cf231d0a84eec0676712975ff8e3f143291979e9 Mon Sep 17 00:00:00 2001 From: cmhu <2657262686@qq.com> Date: Tue, 21 Nov 2023 08:03:02 +0000 Subject: [PATCH] 优化弃帧逻辑 --- src/decoder/dvpp/DvppDecoder.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/decoder/dvpp/DvppDecoder.cpp b/src/decoder/dvpp/DvppDecoder.cpp index 1b01ccf..672e4fa 100755 --- a/src/decoder/dvpp/DvppDecoder.cpp +++ b/src/decoder/dvpp/DvppDecoder.cpp @@ -712,13 +712,26 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o bool bCached = false; if(width > 0 && height > 0 && outputSize > 0){ + if (!m_bReal) { + while(m_bRunning) { + // 非实时流,即为文件情形,因为不存在花屏问题,为保证不丢帧,这里做个循环等待 + m_decoded_data_queue_mtx.lock(); + if(m_decoded_data_queue.size() > 5){ + m_decoded_data_queue_mtx.unlock(); + std::this_thread::sleep_for(std::chrono::milliseconds(5)); + continue; + } + m_decoded_data_queue_mtx.unlock(); + break; + } + } // cout << m_dec_name << " 解码时间间隔: " << get_cur_time_ms() - last_ts << endl; // last_ts = get_cur_time_ms(); // 换成解码后数据, 这里这样做的是为了保证解码一直持续进行,避免后续操作阻碍文件读取和解码从而导致花屏 m_decoded_data_queue_mtx.lock(); - if(m_decoded_data_queue.size() <= 5) { + if(m_decoded_data_queue.size() <= 25) { DvppDataMemory* mem = new DvppDataMemory(width, width_stride, height, height_stride, outputSize, m_dec_name, to_string(m_dvpp_deviceId), false, frame_nb, (unsigned char *)outputDataDev); if(mem){ m_decoded_data_queue.push(mem); -- libgit2 0.21.4