From 6042f34b2b21e9eac2ce8588c5758b6f1e7f788b Mon Sep 17 00:00:00 2001 From: fiss <2657262686@qq.com> Date: Thu, 16 Mar 2023 10:44:41 +0000 Subject: [PATCH] 代码优化 --- src/demo/main_dvpp.cpp | 1 + src/dvpp/DvppDec.cpp | 28 +++++++++++----------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/demo/main_dvpp.cpp b/src/demo/main_dvpp.cpp index 6a9e8e3..b5366d7 100644 --- a/src/demo/main_dvpp.cpp +++ b/src/demo/main_dvpp.cpp @@ -287,6 +287,7 @@ int main(int argc, char* argv[]){ int i = 0; createDvppDecoder(i, gpuid, 0); + i++; while (true) { diff --git a/src/dvpp/DvppDec.cpp b/src/dvpp/DvppDec.cpp index 7282494..763ff93 100644 --- a/src/dvpp/DvppDec.cpp +++ b/src/dvpp/DvppDec.cpp @@ -129,21 +129,14 @@ static void *ReportThd(void *arg) } void DvppDec::doProcessReport(){ - // aclrtContext thdContext = nullptr; - // CHECK_AND_RETURN_NOVALUE(aclrtCreateContext(&thdContext, m_dvpp_deviceId), "aclrtCreateContext failed"); CHECK_AND_RETURN_NOVALUE(aclrtSetCurrentContext(m_context), "aclrtSetCurrentContext failed"); // 阻塞等待vdec线程开始 int ret; while (!m_bExitReportThd) { - ret = aclrtProcessReport(1000); - if (ret != ACL_ERROR_NONE) { - cout << "device: " << m_dvpp_deviceId << ", chn: " << m_dvpp_channel << ", aclrtProcessReport failed, ret: " << ret << endl; - } + aclrtProcessReport(1000); } - - // CHECK_AND_RETURN_NOVALUE(aclrtDestroyContext(thdContext), "aclrtDestroyContext failed"); } static int count_frame = 0; @@ -192,7 +185,7 @@ void DvppDec::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *outpu // 保存vdec结果 if(count_frame > 45 && count_frame < 50) { - string file_name = "./yuv_pic/vdec_out"+ m_dec_name +".rgb" ; + string file_name = "./yuv_pic/vdec_out_"+ m_dec_name +".rgb" ; FILE *outputFile = fopen(file_name.c_str(), "a"); if(outputFile){ fwrite(vdecHostAddr, data_size, sizeof(char), outputFile); @@ -398,23 +391,24 @@ int DvppDec::sentFrame(aclvdecChannelDesc *vdecChannelDesc, uint64_t frame_count // user_data->startTime = startTime; user_data->sendTime = UtilTools::get_cur_time_ms(); user_data->self = this; - // user_data->inBufNode = bufNode; - cout << "send frame" << endl; - CHECK_NOT_RETURN(aclvdecSendFrame(vdecChannelDesc, input_stream_desc, output_pic_desc, nullptr, reinterpret_cast(user_data)), - "aclvdecSendFrame failed"); + + ret = aclvdecSendFrame(vdecChannelDesc, input_stream_desc, output_pic_desc, nullptr, reinterpret_cast(user_data)); + if(ret != ACL_ERROR_NONE){ + cout << "aclvdecSendFrame failed" << endl; + m_pktQueueptr->addHead(); + av_packet_unref(pkt); + break; + } m_vdecQueue.addTail(); - m_pktQueueptr->addHead(); - av_packet_unref(pkt); - return 0; }while (0); if(input_stream_desc){ CHECK_NOT_RETURN(acldvppDestroyStreamDesc(input_stream_desc), "acldvppDestroyStreamDesc failed"); } - if(output_pic_desc){ + if(output_pic_desc){ CHECK_NOT_RETURN(acldvppDestroyPicDesc(output_pic_desc), "acldvppDestroyPicDesc failed"); } -- libgit2 0.21.4