Commit 207d694cb4324a55d89e1cae56b64c7b10b93c97
1 parent
6042f34b
代码优化
Showing
1 changed file
with
41 additions
and
37 deletions
src/dvpp/DvppDec.cpp
@@ -273,6 +273,7 @@ void DvppDec::decode_thread(){ | @@ -273,6 +273,7 @@ void DvppDec::decode_thread(){ | ||
273 | // dvpp解码参数 | 273 | // dvpp解码参数 |
274 | CHECK_AND_RETURN_NOVALUE(aclrtSetCurrentContext(m_context), "aclrtSetCurrentContext failed"); | 274 | CHECK_AND_RETURN_NOVALUE(aclrtSetCurrentContext(m_context), "aclrtSetCurrentContext failed"); |
275 | 275 | ||
276 | + m_bExitReportThd = false; | ||
276 | pthread_t report_thread; | 277 | pthread_t report_thread; |
277 | ret = pthread_create(&report_thread, nullptr, ReportThd, (void *)this); | 278 | ret = pthread_create(&report_thread, nullptr, ReportThd, (void *)this); |
278 | if(ret != 0){ | 279 | if(ret != 0){ |
@@ -286,50 +287,53 @@ void DvppDec::decode_thread(){ | @@ -286,50 +287,53 @@ void DvppDec::decode_thread(){ | ||
286 | cout << "aclvdecCreateChannelDesc failed"; | 287 | cout << "aclvdecCreateChannelDesc failed"; |
287 | return; | 288 | return; |
288 | } | 289 | } |
289 | - // 创建 channel dec结构体 | ||
290 | - // 通道ID在dvpp层面为0~31 | ||
291 | - CHECK_AND_RETURN_NOVALUE(aclvdecSetChannelDescChannelId(vdecChannelDesc, m_dvpp_channel), "aclvdecSetChannelDescChannelId failed"); | ||
292 | - CHECK_AND_RETURN_NOVALUE(aclvdecSetChannelDescThreadId(vdecChannelDesc, report_thread), "aclvdecSetChannelDescThreadId failed"); | ||
293 | - CHECK_AND_RETURN_NOVALUE(aclvdecSetChannelDescCallback(vdecChannelDesc, VdecCallback), "aclvdecSetChannelDescCallback failed"); | ||
294 | - CHECK_AND_RETURN_NOVALUE(aclvdecSetChannelDescEnType(vdecChannelDesc, enType), "aclvdecSetChannelDescEnType failed"); | ||
295 | - CHECK_AND_RETURN_NOVALUE(aclvdecSetChannelDescOutPicFormat(vdecChannelDesc, PIXEL_FORMAT_YUV_SEMIPLANAR_420), "aclvdecSetChannelDescOutPicFormat failed"); | ||
296 | - CHECK_AND_RETURN_NOVALUE(aclvdecCreateChannel(vdecChannelDesc), "aclvdecCreateChannel failed"); | ||
297 | - | ||
298 | - uint64_t frame_count = 0; | ||
299 | - bool bBreak = false; | ||
300 | - while (m_bRunning) | ||
301 | - { | ||
302 | - int ret = sentFrame(vdecChannelDesc, frame_count); | ||
303 | - if(ret == 2){ | ||
304 | - break; | ||
305 | - bBreak = true; | ||
306 | - }else if(ret == 1){ | ||
307 | - continue; | ||
308 | - } | ||
309 | - | ||
310 | - frame_count++; | ||
311 | - } | ||
312 | - | ||
313 | - // 尽量保证数据全部解码完成 | ||
314 | - int sum = 0; | ||
315 | - if(!bBreak){ | ||
316 | - while(!m_pktQueueptr->isEmpty()){ | 290 | + do{ |
291 | + // 创建 channel dec结构体 | ||
292 | + // 通道ID在dvpp层面为0~31 | ||
293 | + CHECK_AND_BREAK(aclvdecSetChannelDescChannelId(vdecChannelDesc, m_dvpp_channel), "aclvdecSetChannelDescChannelId failed"); | ||
294 | + CHECK_AND_BREAK(aclvdecSetChannelDescThreadId(vdecChannelDesc, report_thread), "aclvdecSetChannelDescThreadId failed"); | ||
295 | + CHECK_AND_BREAK(aclvdecSetChannelDescCallback(vdecChannelDesc, VdecCallback), "aclvdecSetChannelDescCallback failed"); | ||
296 | + CHECK_AND_BREAK(aclvdecSetChannelDescEnType(vdecChannelDesc, enType), "aclvdecSetChannelDescEnType failed"); | ||
297 | + CHECK_AND_BREAK(aclvdecSetChannelDescOutPicFormat(vdecChannelDesc, PIXEL_FORMAT_YUV_SEMIPLANAR_420), "aclvdecSetChannelDescOutPicFormat failed"); | ||
298 | + CHECK_AND_BREAK(aclvdecCreateChannel(vdecChannelDesc), "aclvdecCreateChannel failed"); | ||
299 | + | ||
300 | + uint64_t frame_count = 0; | ||
301 | + bool bBreak = false; | ||
302 | + while (m_bRunning) | ||
303 | + { | ||
317 | int ret = sentFrame(vdecChannelDesc, frame_count); | 304 | int ret = sentFrame(vdecChannelDesc, frame_count); |
318 | if(ret == 2){ | 305 | if(ret == 2){ |
319 | break; | 306 | break; |
307 | + bBreak = true; | ||
308 | + }else if(ret == 1){ | ||
309 | + continue; | ||
320 | } | 310 | } |
321 | - std::this_thread::sleep_for(std::chrono::milliseconds(3)); | ||
322 | - sum++; | ||
323 | - if(sum > 40){ | ||
324 | - // 避免卡死 | ||
325 | - break; | 311 | + |
312 | + frame_count++; | ||
313 | + } | ||
314 | + | ||
315 | + // 尽量保证数据全部解码完成 | ||
316 | + int sum = 0; | ||
317 | + if(!bBreak){ | ||
318 | + while(!m_pktQueueptr->isEmpty()){ | ||
319 | + int ret = sentFrame(vdecChannelDesc, frame_count); | ||
320 | + if(ret == 2){ | ||
321 | + break; | ||
322 | + } | ||
323 | + std::this_thread::sleep_for(std::chrono::milliseconds(3)); | ||
324 | + sum++; | ||
325 | + if(sum > 40){ | ||
326 | + // 避免卡死 | ||
327 | + break; | ||
328 | + } | ||
326 | } | 329 | } |
327 | } | 330 | } |
328 | - } | ||
329 | - | ||
330 | - sendVdecEos(vdecChannelDesc); | 331 | + |
332 | + sendVdecEos(vdecChannelDesc); | ||
331 | 333 | ||
332 | - CHECK_NOT_RETURN(aclvdecDestroyChannel(vdecChannelDesc), "aclvdecDestroyChannel failed"); | 334 | + CHECK_NOT_RETURN(aclvdecDestroyChannel(vdecChannelDesc), "aclvdecDestroyChannel failed"); |
335 | + }while(0); | ||
336 | + | ||
333 | CHECK_NOT_RETURN(aclvdecDestroyChannelDesc(vdecChannelDesc), "aclvdecDestroyChannelDesc failed"); | 337 | CHECK_NOT_RETURN(aclvdecDestroyChannelDesc(vdecChannelDesc), "aclvdecDestroyChannelDesc failed"); |
334 | 338 | ||
335 | // report_thread 需后于destroy退出 | 339 | // report_thread 需后于destroy退出 |