Commit cf231d0a84eec0676712975ff8e3f143291979e9

Authored by Hu Chunming
1 parent c19334fe

优化弃帧逻辑

src/decoder/dvpp/DvppDecoder.cpp
@@ -712,13 +712,26 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o @@ -712,13 +712,26 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o
712 712
713 bool bCached = false; 713 bool bCached = false;
714 if(width > 0 && height > 0 && outputSize > 0){ 714 if(width > 0 && height > 0 && outputSize > 0){
  715 + if (!m_bReal) {
  716 + while(m_bRunning) {
  717 + // 非实时流,即为文件情形,因为不存在花屏问题,为保证不丢帧,这里做个循环等待
  718 + m_decoded_data_queue_mtx.lock();
  719 + if(m_decoded_data_queue.size() > 5){
  720 + m_decoded_data_queue_mtx.unlock();
  721 + std::this_thread::sleep_for(std::chrono::milliseconds(5));
  722 + continue;
  723 + }
  724 + m_decoded_data_queue_mtx.unlock();
  725 + break;
  726 + }
  727 + }
715 728
716 // cout << m_dec_name << " 解码时间间隔: " << get_cur_time_ms() - last_ts << endl; 729 // cout << m_dec_name << " 解码时间间隔: " << get_cur_time_ms() - last_ts << endl;
717 // last_ts = get_cur_time_ms(); 730 // last_ts = get_cur_time_ms();
718 731
719 // 换成解码后数据, 这里这样做的是为了保证解码一直持续进行,避免后续操作阻碍文件读取和解码从而导致花屏 732 // 换成解码后数据, 这里这样做的是为了保证解码一直持续进行,避免后续操作阻碍文件读取和解码从而导致花屏
720 m_decoded_data_queue_mtx.lock(); 733 m_decoded_data_queue_mtx.lock();
721 - if(m_decoded_data_queue.size() <= 5) { 734 + if(m_decoded_data_queue.size() <= 25) {
722 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); 735 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);
723 if(mem){ 736 if(mem){
724 m_decoded_data_queue.push(mem); 737 m_decoded_data_queue.push(mem);