Commit fd3e06eedb25eb7e056b5fecbd400fc775376b94

Authored by Hu Chunming
1 parent d02c9a53

代码优化,补充测试案例

src/decoder/dvpp/DvppDecoder.cpp
... ... @@ -221,7 +221,6 @@ AVCodecContext* DvppDecoder::init_FFmpeg(FFDecConfig config){
221 221 frame_height = codecpar->height;
222 222 pix_fmt = (AVPixelFormat)codecpar->format;
223 223  
224   - m_bResize = config.resize;
225 224 calcOutResolution(frame_width, frame_height);
226 225  
227 226 if (stream->avg_frame_rate.den) {
... ... @@ -346,6 +345,7 @@ int DvppDecoder::getVdecType(int videoType, int profile)
346 345 break;
347 346 }
348 347  
  348 + m_bResize = cfg.resize;
349 349 m_vpcUtils.init(m_dvpp_deviceId);
350 350  
351 351 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
843 843 }
844 844  
845 845 if(mem){
  846 + m_decoded_data_queue_mtx.lock();
846 847 m_decoded_data_queue.push(mem);
  848 + m_decoded_data_queue_mtx.unlock();
847 849 bCached = true;
848 850 }
849 851 }
... ... @@ -901,7 +903,7 @@ void DvppDecoder::display_thread() {
901 903 m_decoded_data_queue_mtx.unlock();
902 904  
903 905 if (mem) {
904   - if ((m_frameSkip == 1 || index % m_frameSkip == 0) && post_decoded_cbk){
  906 + if ((m_frameSkip == 1 || index % m_frameSkip == 0) && post_decoded_cbk) {
905 907 post_decoded_cbk(m_postDecArg, mem);
906 908 } else {
907 909 delete mem;
... ...
src/decoder/dvpp/FFRecoderTaskManager.cpp
... ... @@ -271,6 +271,8 @@ void FFRecoderTaskManager::recode_thread() {
271 271 m_recoderinfo_list_mtx.unlock();
272 272 }
273 273  
  274 + m_recoderinfo_list.clear();
  275 +
274 276 LOG_INFO("recode_thread2 end.");
275 277 }
276 278  
... ... @@ -290,6 +292,8 @@ void FFRecoderTaskManager::close() {
290 292 dataPkt = nullptr;
291 293 m_pkt_list_short.pop_front();
292 294 }
  295 +
  296 + m_keyframe_nb_list.clear();
293 297 }
294 298  
295 299 void FFRecoderTaskManager::set_mq_callback(mq_callback_t cb) {
... ...
src/demo/demo.cpp
... ... @@ -983,13 +983,13 @@ string createTask(void *handle, std::vector<algorithm_type_t> algor_vec, int gi,
983 983 tparam.ipc_url = "/data/share/data/Street.uvf";
984 984 break;
985 985 case 22:
986   - tparam.ipc_url = "/data/share/data/Street.uvf";
  986 + tparam.ipc_url = "/home/cmhu/data/traffic_1.mp4";
987 987 break;
988 988 case 23:
989   - tparam.ipc_url = "/data/share/data/Street.uvf";
  989 + tparam.ipc_url = "/home/cmhu/data/traffic_2.mp4";
990 990 break;
991 991 case 24:
992   - tparam.ipc_url = "/data/share/data/Street.uvf";
  992 + tparam.ipc_url = "/home/cmhu/data/traffic_3.mp4";
993 993 break;
994 994 case 25:
995 995 // 公安内网
... ... @@ -1252,45 +1252,47 @@ void test_gpu(int gpuID){
1252 1252  
1253 1253 // createTask(handle, algor_vec2, 4, false);
1254 1254  
1255   - // int task_index = 0;
1256   - // while (true)
1257   - // {
1258   - // int task_count = count_running_task(handle);
1259   - // if (task_count < 7)
1260   - // {
1261   - // // if (task_index > 7)
1262   - // // {
1263   - // // task_index = 0;
1264   - // // break;
1265   - // // }
  1255 + int task_index = 0;
  1256 + while (true)
  1257 + {
  1258 + int task_count = count_running_task(handle);
  1259 + if (task_count < 7)
  1260 + {
  1261 + // if (task_index > 7)
  1262 + // {
  1263 + // task_index = 0;
  1264 + // break;
  1265 + // }
1266 1266  
1267   - // createTask(handle, algor_vec2, 28, false);
1268   - // task_index++;
1269   - // createTask(handle, algor_vec2, 29, false);
1270   - // task_index++;
1271   - // }
  1267 + createTask(handle, algor_vec2, 28, false);
  1268 + task_index++;
  1269 + createTask(handle, algor_vec2, 29, false);
  1270 + task_index++;
  1271 + }
1272 1272  
1273   - // std::this_thread::sleep_for(std::chrono::seconds(5));
1274   - // }
  1273 + std::this_thread::sleep_for(std::chrono::seconds(5));
  1274 + }
1275 1275  
  1276 +
  1277 + // createTask(handle, algor_vec2, 28, false);
  1278 + // createTask(handle, algor_vec2, 29, false);
1276 1279  
1277 1280  
1278   - char ch = 'a';
1279   - while (ch != 'q') {
1280   - ch = getchar();
1281   - switch (ch)
1282   - {
1283   - case 'a':
1284   - createTask(handle, algor_vec2, 28, false);
1285   - break;
1286   - case 'c':
1287   - close_all_task(handle);
1288   - break;
1289   - default:
1290   - break;
1291   - }
1292   -
1293   - }
  1281 + // char ch = 'a';
  1282 + // while (ch != 'q') {
  1283 + // ch = getchar();
  1284 + // switch (ch)
  1285 + // {
  1286 + // case 'a':
  1287 + // createTask(handle, algor_vec2, 22, false);
  1288 + // break;
  1289 + // case 'c':
  1290 + // close_all_task(handle);
  1291 + // break;
  1292 + // default:
  1293 + // break;
  1294 + // }
  1295 + // }
1294 1296  
1295 1297 // finish_task(handle, (char*)task_id.data(), 0);
1296 1298  
... ...