From fd3e06eedb25eb7e056b5fecbd400fc775376b94 Mon Sep 17 00:00:00 2001 From: cmhu <2657262686@qq.com> Date: Tue, 27 Aug 2024 16:01:04 +0800 Subject: [PATCH] 代码优化,补充测试案例 --- src/decoder/dvpp/DvppDecoder.cpp | 6 ++++-- src/decoder/dvpp/FFRecoderTaskManager.cpp | 4 ++++ src/demo/demo.cpp | 76 +++++++++++++++++++++++++++++++++++++++------------------------------------- 3 files changed, 47 insertions(+), 39 deletions(-) diff --git a/src/decoder/dvpp/DvppDecoder.cpp b/src/decoder/dvpp/DvppDecoder.cpp index b34a390..00a60fc 100644 --- a/src/decoder/dvpp/DvppDecoder.cpp +++ b/src/decoder/dvpp/DvppDecoder.cpp @@ -221,7 +221,6 @@ AVCodecContext* DvppDecoder::init_FFmpeg(FFDecConfig config){ frame_height = codecpar->height; pix_fmt = (AVPixelFormat)codecpar->format; - m_bResize = config.resize; calcOutResolution(frame_width, frame_height); if (stream->avg_frame_rate.den) { @@ -346,6 +345,7 @@ int DvppDecoder::getVdecType(int videoType, int profile) break; } + m_bResize = cfg.resize; m_vpcUtils.init(m_dvpp_deviceId); LOG_INFO("[{}]- init vdpp success! device:{} channel:{}", m_dec_name, m_dvpp_deviceId, m_dvpp_channel); @@ -843,7 +843,9 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o } if(mem){ + m_decoded_data_queue_mtx.lock(); m_decoded_data_queue.push(mem); + m_decoded_data_queue_mtx.unlock(); bCached = true; } } @@ -901,7 +903,7 @@ void DvppDecoder::display_thread() { m_decoded_data_queue_mtx.unlock(); if (mem) { - if ((m_frameSkip == 1 || index % m_frameSkip == 0) && post_decoded_cbk){ + if ((m_frameSkip == 1 || index % m_frameSkip == 0) && post_decoded_cbk) { post_decoded_cbk(m_postDecArg, mem); } else { delete mem; diff --git a/src/decoder/dvpp/FFRecoderTaskManager.cpp b/src/decoder/dvpp/FFRecoderTaskManager.cpp index 20b895a..2f653b5 100644 --- a/src/decoder/dvpp/FFRecoderTaskManager.cpp +++ b/src/decoder/dvpp/FFRecoderTaskManager.cpp @@ -271,6 +271,8 @@ void FFRecoderTaskManager::recode_thread() { m_recoderinfo_list_mtx.unlock(); } + m_recoderinfo_list.clear(); + LOG_INFO("recode_thread2 end."); } @@ -290,6 +292,8 @@ void FFRecoderTaskManager::close() { dataPkt = nullptr; m_pkt_list_short.pop_front(); } + + m_keyframe_nb_list.clear(); } void FFRecoderTaskManager::set_mq_callback(mq_callback_t cb) { diff --git a/src/demo/demo.cpp b/src/demo/demo.cpp index 3ad417b..25d9178 100755 --- a/src/demo/demo.cpp +++ b/src/demo/demo.cpp @@ -983,13 +983,13 @@ string createTask(void *handle, std::vector algor_vec, int gi, tparam.ipc_url = "/data/share/data/Street.uvf"; break; case 22: - tparam.ipc_url = "/data/share/data/Street.uvf"; + tparam.ipc_url = "/home/cmhu/data/traffic_1.mp4"; break; case 23: - tparam.ipc_url = "/data/share/data/Street.uvf"; + tparam.ipc_url = "/home/cmhu/data/traffic_2.mp4"; break; case 24: - tparam.ipc_url = "/data/share/data/Street.uvf"; + tparam.ipc_url = "/home/cmhu/data/traffic_3.mp4"; break; case 25: // 公安内网 @@ -1252,45 +1252,47 @@ void test_gpu(int gpuID){ // createTask(handle, algor_vec2, 4, false); - // int task_index = 0; - // while (true) - // { - // int task_count = count_running_task(handle); - // if (task_count < 7) - // { - // // if (task_index > 7) - // // { - // // task_index = 0; - // // break; - // // } + int task_index = 0; + while (true) + { + int task_count = count_running_task(handle); + if (task_count < 7) + { + // if (task_index > 7) + // { + // task_index = 0; + // break; + // } - // createTask(handle, algor_vec2, 28, false); - // task_index++; - // createTask(handle, algor_vec2, 29, false); - // task_index++; - // } + createTask(handle, algor_vec2, 28, false); + task_index++; + createTask(handle, algor_vec2, 29, false); + task_index++; + } - // std::this_thread::sleep_for(std::chrono::seconds(5)); - // } + std::this_thread::sleep_for(std::chrono::seconds(5)); + } + + // createTask(handle, algor_vec2, 28, false); + // createTask(handle, algor_vec2, 29, false); - char ch = 'a'; - while (ch != 'q') { - ch = getchar(); - switch (ch) - { - case 'a': - createTask(handle, algor_vec2, 28, false); - break; - case 'c': - close_all_task(handle); - break; - default: - break; - } - - } + // char ch = 'a'; + // while (ch != 'q') { + // ch = getchar(); + // switch (ch) + // { + // case 'a': + // createTask(handle, algor_vec2, 22, false); + // break; + // case 'c': + // close_all_task(handle); + // break; + // default: + // break; + // } + // } // finish_task(handle, (char*)task_id.data(), 0); -- libgit2 0.21.4