Commit 458962a016ebc2cf06a49fc311d285cba85ca27d
1 parent
44a5c5b0
dvpp操作失败直接abort;VpcUtils改为单例
Showing
6 changed files
with
113 additions
and
129 deletions
src/decoder/dvpp/DvppDataMemory.hpp
@@ -20,6 +20,7 @@ public: | @@ -20,6 +20,7 @@ public: | ||
20 | int ret = acldvppMalloc((void **)&pHwRgb, data_size); | 20 | int ret = acldvppMalloc((void **)&pHwRgb, data_size); |
21 | if(ret != ACL_ERROR_NONE){ | 21 | if(ret != ACL_ERROR_NONE){ |
22 | LOG_ERROR("[{}]- acldvppMalloc failed", id); | 22 | LOG_ERROR("[{}]- acldvppMalloc failed", id); |
23 | + std::abort(); | ||
23 | } | 24 | } |
24 | } | 25 | } |
25 | 26 | ||
@@ -40,14 +41,14 @@ public: | @@ -40,14 +41,14 @@ public: | ||
40 | int ret = acldvppMalloc((void **)&pHwRgb, data_size); | 41 | int ret = acldvppMalloc((void **)&pHwRgb, data_size); |
41 | if(ret != ACL_ERROR_NONE){ | 42 | if(ret != ACL_ERROR_NONE){ |
42 | LOG_ERROR("[{}]- acldvppMalloc failed", pSrc->getId()); | 43 | LOG_ERROR("[{}]- acldvppMalloc failed", pSrc->getId()); |
43 | - return; | 44 | + std::abort(); |
44 | } | 45 | } |
45 | 46 | ||
46 | ret = aclrtMemcpy(pHwRgb, data_size, pSrc->getMem(), pSrc->getSize(), ACL_MEMCPY_DEVICE_TO_DEVICE); | 47 | ret = aclrtMemcpy(pHwRgb, data_size, pSrc->getMem(), pSrc->getSize(), ACL_MEMCPY_DEVICE_TO_DEVICE); |
47 | if(ret != ACL_ERROR_NONE){ | 48 | if(ret != ACL_ERROR_NONE){ |
48 | acldvppFree(pHwRgb); | 49 | acldvppFree(pHwRgb); |
49 | LOG_ERROR("[{}]- aclrtMemcpy failed", pSrc->getId()); | 50 | LOG_ERROR("[{}]- aclrtMemcpy failed", pSrc->getId()); |
50 | - return; | 51 | + std::abort(); |
51 | } | 52 | } |
52 | 53 | ||
53 | data_type = 2; | 54 | data_type = 2; |
@@ -64,6 +65,7 @@ public: | @@ -64,6 +65,7 @@ public: | ||
64 | int ret = acldvppFree(pHwRgb); | 65 | int ret = acldvppFree(pHwRgb); |
65 | if(ret != ACL_ERROR_NONE){ | 66 | if(ret != ACL_ERROR_NONE){ |
66 | LOG_ERROR("[{}]- acldvppFree failed", id); | 67 | LOG_ERROR("[{}]- acldvppFree failed", id); |
68 | + std::abort(); | ||
67 | } | 69 | } |
68 | pHwRgb = nullptr; | 70 | pHwRgb = nullptr; |
69 | } | 71 | } |
src/decoder/dvpp/DvppDecoder.cpp
1 | #include "DvppDecoder.h" | 1 | #include "DvppDecoder.h" |
2 | #include "DvppSourceManager.h" | 2 | #include "DvppSourceManager.h" |
3 | 3 | ||
4 | +#include "VpcUtils.h" | ||
4 | 5 | ||
5 | -#define CHECK_AND_RETURN(ret, message) \ | ||
6 | - if(ret != 0) {LOG_ERROR("[{}]- {}", m_dec_name, message); return ret;} | ||
7 | -#define CHECK_NOT_RETURN(ret, message) \ | ||
8 | - if(ret != 0) {LOG_ERROR("[{}]- {}", m_dec_name, message);} | ||
9 | -#define CHECK_AND_RETURN_NOVALUE(ret, message) \ | ||
10 | - if(ret != 0) {LOG_ERROR("[{}]- {}", m_dec_name, message); return;} | ||
11 | -#define CHECK_AND_BREAK(ret, message) \ | ||
12 | - if(ret != 0) {LOG_ERROR("[{}]- {}", m_dec_name, message); break;} | ||
13 | - | ||
14 | - | 6 | +#define ACL_CHECK_AND_ABORT(ret, message) \ |
7 | + if(ret != 0) {LOG_ERROR("[{}]- {}:{}", m_dec_name, message, ret); std::abort();} | ||
15 | 8 | ||
16 | 9 | ||
17 | struct Vdec_CallBack_UserData { | 10 | struct Vdec_CallBack_UserData { |
@@ -328,14 +321,13 @@ int DvppDecoder::getVdecType(int videoType, int profile) | @@ -328,14 +321,13 @@ int DvppDecoder::getVdecType(int videoType, int profile) | ||
328 | 321 | ||
329 | m_dvpp_deviceId = atoi(cfg.gpuid.c_str()); | 322 | m_dvpp_deviceId = atoi(cfg.gpuid.c_str()); |
330 | 323 | ||
324 | + VpcUtils* pUtil = VpcUtils::getInstance(); | ||
325 | + pUtil->init(m_dvpp_deviceId); | ||
326 | + | ||
331 | post_decoded_cbk = cfg.post_decoded_cbk; | 327 | post_decoded_cbk = cfg.post_decoded_cbk; |
332 | 328 | ||
333 | do{ | 329 | do{ |
334 | - aclError ret = aclrtCreateContext(&m_context, m_dvpp_deviceId); | ||
335 | - if (ret != ACL_ERROR_NONE) { | ||
336 | - LOG_ERROR("[{}]-aclrtCreateContext failed !", m_dec_name); | ||
337 | - break; | ||
338 | - } | 330 | + ACL_CHECK_AND_ABORT(aclrtCreateContext(&m_context, m_dvpp_deviceId), "aclrtCreateContext failed !"); |
339 | 331 | ||
340 | // DvppSourceManager 创建时包含 aclInit,析构时包含 aclFinalize | 332 | // DvppSourceManager 创建时包含 aclInit,析构时包含 aclFinalize |
341 | DvppSourceManager* pSrcMgr = DvppSourceManager::getInstance(); | 333 | DvppSourceManager* pSrcMgr = DvppSourceManager::getInstance(); |
@@ -346,7 +338,6 @@ int DvppDecoder::getVdecType(int videoType, int profile) | @@ -346,7 +338,6 @@ int DvppDecoder::getVdecType(int videoType, int profile) | ||
346 | } | 338 | } |
347 | 339 | ||
348 | m_bResize = cfg.resize; | 340 | m_bResize = cfg.resize; |
349 | - m_vpcUtils.init(m_dvpp_deviceId); | ||
350 | 341 | ||
351 | LOG_INFO("[{}]- init vdpp success! device:{} channel:{}", m_dec_name, m_dvpp_deviceId, m_dvpp_channel); | 342 | LOG_INFO("[{}]- init vdpp success! device:{} channel:{}", m_dec_name, m_dvpp_deviceId, m_dvpp_channel); |
352 | return true; | 343 | return true; |
@@ -440,11 +431,7 @@ static int snap_count = 0; | @@ -440,11 +431,7 @@ static int snap_count = 0; | ||
440 | 431 | ||
441 | DeviceMemory* DvppDecoder::snapshot(){ | 432 | DeviceMemory* DvppDecoder::snapshot(){ |
442 | 433 | ||
443 | - int ret = aclrtSetCurrentContext(m_context); | ||
444 | - if(ret != ACL_ERROR_NONE){ | ||
445 | - LOG_ERROR("[{}]- aclrtSetCurrentContext failed", m_dec_name); | ||
446 | - return nullptr; | ||
447 | - } | 434 | + ACL_CHECK_AND_ABORT(aclrtSetCurrentContext(m_context), "aclrtSetCurrentContext failed !"); |
448 | 435 | ||
449 | // 注意有锁 | 436 | // 注意有锁 |
450 | DeviceMemory* snapshot_mem = nullptr; | 437 | DeviceMemory* snapshot_mem = nullptr; |
@@ -522,26 +509,23 @@ void DvppDecoder::read_thread() { | @@ -522,26 +509,23 @@ void DvppDecoder::read_thread() { | ||
522 | aclvdecChannelDesc *vdecChannelDesc = nullptr; | 509 | aclvdecChannelDesc *vdecChannelDesc = nullptr; |
523 | 510 | ||
524 | do { | 511 | do { |
525 | - int ret = aclrtSetCurrentContext(m_context); | ||
526 | - if(ret != ACL_ERROR_NONE){ | ||
527 | - LOG_ERROR("[{}]- aclrtSetCurrentContext failed", m_dec_name); | ||
528 | - break; | ||
529 | - } | 512 | + aclrtSetDevice(m_dvpp_deviceId); |
513 | + ACL_CHECK_AND_ABORT(aclrtSetCurrentContext(m_context), "aclrtSetCurrentContext failed !"); | ||
530 | 514 | ||
531 | vdecChannelDesc = aclvdecCreateChannelDesc(); | 515 | vdecChannelDesc = aclvdecCreateChannelDesc(); |
532 | if (vdecChannelDesc == nullptr) { | 516 | if (vdecChannelDesc == nullptr) { |
533 | LOG_ERROR("[{}]- aclvdecCreateChannelDesc failed", m_dec_name); | 517 | LOG_ERROR("[{}]- aclvdecCreateChannelDesc failed", m_dec_name); |
534 | - break; | 518 | + std::abort(); |
535 | } | 519 | } |
536 | 520 | ||
537 | // 创建 channel dec结构体 | 521 | // 创建 channel dec结构体 |
538 | // 通道ID在dvpp层面为0~31 | 522 | // 通道ID在dvpp层面为0~31 |
539 | - CHECK_AND_BREAK(aclvdecSetChannelDescChannelId(vdecChannelDesc, m_dvpp_channel), "aclvdecSetChannelDescChannelId failed"); | ||
540 | - CHECK_AND_BREAK(aclvdecSetChannelDescThreadId(vdecChannelDesc, report_thread), "aclvdecSetChannelDescThreadId failed"); | ||
541 | - CHECK_AND_BREAK(aclvdecSetChannelDescCallback(vdecChannelDesc, VdecCallback), "aclvdecSetChannelDescCallback failed"); | ||
542 | - CHECK_AND_BREAK(aclvdecSetChannelDescEnType(vdecChannelDesc, m_enType), "aclvdecSetChannelDescEnType failed"); | ||
543 | - CHECK_AND_BREAK(aclvdecSetChannelDescOutPicFormat(vdecChannelDesc, PIXEL_FORMAT_YUV_SEMIPLANAR_420), "aclvdecSetChannelDescOutPicFormat failed"); | ||
544 | - CHECK_AND_BREAK(aclvdecCreateChannel(vdecChannelDesc), "aclvdecCreateChannel failed"); | 523 | + ACL_CHECK_AND_ABORT(aclvdecSetChannelDescChannelId(vdecChannelDesc, m_dvpp_channel), "aclvdecSetChannelDescChannelId failed"); |
524 | + ACL_CHECK_AND_ABORT(aclvdecSetChannelDescThreadId(vdecChannelDesc, report_thread), "aclvdecSetChannelDescThreadId failed"); | ||
525 | + ACL_CHECK_AND_ABORT(aclvdecSetChannelDescCallback(vdecChannelDesc, VdecCallback), "aclvdecSetChannelDescCallback failed"); | ||
526 | + ACL_CHECK_AND_ABORT(aclvdecSetChannelDescEnType(vdecChannelDesc, m_enType), "aclvdecSetChannelDescEnType failed"); | ||
527 | + ACL_CHECK_AND_ABORT(aclvdecSetChannelDescOutPicFormat(vdecChannelDesc, PIXEL_FORMAT_YUV_SEMIPLANAR_420), "aclvdecSetChannelDescOutPicFormat failed"); | ||
528 | + ACL_CHECK_AND_ABORT(aclvdecCreateChannel(vdecChannelDesc), "aclvdecCreateChannel failed"); | ||
545 | 529 | ||
546 | unsigned long long frame_nb = 0; | 530 | unsigned long long frame_nb = 0; |
547 | AVPacket* pkt = av_packet_alloc(); | 531 | AVPacket* pkt = av_packet_alloc(); |
@@ -638,15 +622,15 @@ void DvppDecoder::read_thread() { | @@ -638,15 +622,15 @@ void DvppDecoder::read_thread() { | ||
638 | } while (0); | 622 | } while (0); |
639 | 623 | ||
640 | if (vdecChannelDesc) { | 624 | if (vdecChannelDesc) { |
641 | - CHECK_NOT_RETURN(aclvdecDestroyChannel(vdecChannelDesc), "aclvdecDestroyChannel failed"); | ||
642 | - CHECK_NOT_RETURN(aclvdecDestroyChannelDesc(vdecChannelDesc), "aclvdecDestroyChannelDesc failed"); | 625 | + ACL_CHECK_AND_ABORT(aclvdecDestroyChannel(vdecChannelDesc), "aclvdecDestroyChannel failed"); |
626 | + ACL_CHECK_AND_ABORT(aclvdecDestroyChannelDesc(vdecChannelDesc), "aclvdecDestroyChannelDesc failed"); | ||
643 | vdecChannelDesc = nullptr; | 627 | vdecChannelDesc = nullptr; |
644 | } | 628 | } |
645 | 629 | ||
646 | m_bRunning=false; | 630 | m_bRunning=false; |
647 | 631 | ||
648 | m_bExitReportThd = true; | 632 | m_bExitReportThd = true; |
649 | - CHECK_NOT_RETURN(pthread_join(report_thread, nullptr), "report_thread join failed"); | 633 | + ACL_CHECK_AND_ABORT(pthread_join(report_thread, nullptr), "report_thread join failed"); |
650 | 634 | ||
651 | m_bExitDisplayThd = true; | 635 | m_bExitDisplayThd = true; |
652 | display_thread_.join(); | 636 | display_thread_.join(); |
@@ -672,38 +656,26 @@ int DvppDecoder::sendPkt(aclvdecChannelDesc *vdecChannelDesc, AVPacket* pkt, uns | @@ -672,38 +656,26 @@ int DvppDecoder::sendPkt(aclvdecChannelDesc *vdecChannelDesc, AVPacket* pkt, uns | ||
672 | acldvppStreamDesc *input_stream_desc = nullptr; | 656 | acldvppStreamDesc *input_stream_desc = nullptr; |
673 | acldvppPicDesc *output_pic_desc = nullptr; | 657 | acldvppPicDesc *output_pic_desc = nullptr; |
674 | do{ | 658 | do{ |
675 | - int ret = acldvppMalloc((void **)&vdecInputbuf, pkt->size); | ||
676 | - if(ACL_ERROR_NONE != ret){ | ||
677 | - LOG_ERROR("[{}]- acldvppMalloc failed!, ret:{}", m_dec_name, ret); | ||
678 | - break; | ||
679 | - } | 659 | + int ret = -1; |
680 | 660 | ||
681 | - ret = aclrtMemcpy(vdecInputbuf, pkt->size, pkt->data, pkt->size, ACL_MEMCPY_HOST_TO_DEVICE); | ||
682 | - if(ACL_ERROR_NONE != ret){ | ||
683 | - LOG_ERROR("[{}]- aclrtMemcpy failed", m_dec_name); | ||
684 | - break; | ||
685 | - } | ||
686 | - | ||
687 | - ret = acldvppMalloc((void **)&vdecOutputBuf, m_vdec_out_size); | ||
688 | - if(ret != ACL_ERROR_NONE){ | ||
689 | - LOG_ERROR("[{}]- acldvppMalloc failed", m_dec_name); | ||
690 | - break; | ||
691 | - } | 661 | + ACL_CHECK_AND_ABORT(acldvppMalloc((void **)&vdecInputbuf, pkt->size), "acldvppMalloc failed!"); |
662 | + ACL_CHECK_AND_ABORT(aclrtMemcpy(vdecInputbuf, pkt->size, pkt->data, pkt->size, ACL_MEMCPY_HOST_TO_DEVICE), "aclrtMemcpy failed!"); | ||
663 | + ACL_CHECK_AND_ABORT(acldvppMalloc((void **)&vdecOutputBuf, m_vdec_out_size), "acldvppMalloc failed!"); | ||
692 | 664 | ||
693 | input_stream_desc = acldvppCreateStreamDesc(); | 665 | input_stream_desc = acldvppCreateStreamDesc(); |
694 | if (input_stream_desc == nullptr) { | 666 | if (input_stream_desc == nullptr) { |
695 | LOG_ERROR("[{}]- acldvppCreateStreamDesc failed", m_dec_name); | 667 | LOG_ERROR("[{}]- acldvppCreateStreamDesc failed", m_dec_name); |
696 | - break; | 668 | + std::abort(); |
697 | } | 669 | } |
698 | output_pic_desc = acldvppCreatePicDesc(); | 670 | output_pic_desc = acldvppCreatePicDesc(); |
699 | if (output_pic_desc == nullptr) { | 671 | if (output_pic_desc == nullptr) { |
700 | LOG_ERROR("[{}]- acldvppCreatePicDesc failed", m_dec_name); | 672 | LOG_ERROR("[{}]- acldvppCreatePicDesc failed", m_dec_name); |
701 | - break; | 673 | + std::abort(); |
702 | } | 674 | } |
703 | - CHECK_AND_BREAK(acldvppSetStreamDescData(input_stream_desc, vdecInputbuf), "acldvppSetStreamDescData failed"); | ||
704 | - CHECK_AND_BREAK(acldvppSetStreamDescSize(input_stream_desc, pkt->size), "acldvppSetStreamDescSize failed"); | ||
705 | - CHECK_AND_BREAK(acldvppSetPicDescData(output_pic_desc, vdecOutputBuf), "acldvppSetPicDescData failed"); | ||
706 | - CHECK_AND_BREAK(acldvppSetPicDescSize(output_pic_desc, m_vdec_out_size), "acldvppSetPicDescSize failed"); | 675 | + ACL_CHECK_AND_ABORT(acldvppSetStreamDescData(input_stream_desc, vdecInputbuf), "acldvppSetStreamDescData failed"); |
676 | + ACL_CHECK_AND_ABORT(acldvppSetStreamDescSize(input_stream_desc, pkt->size), "acldvppSetStreamDescSize failed"); | ||
677 | + ACL_CHECK_AND_ABORT(acldvppSetPicDescData(output_pic_desc, vdecOutputBuf), "acldvppSetPicDescData failed"); | ||
678 | + ACL_CHECK_AND_ABORT(acldvppSetPicDescSize(output_pic_desc, m_vdec_out_size), "acldvppSetPicDescSize failed"); | ||
707 | 679 | ||
708 | Vdec_CallBack_UserData *user_data = NULL; | 680 | Vdec_CallBack_UserData *user_data = NULL; |
709 | user_data = new Vdec_CallBack_UserData; | 681 | user_data = new Vdec_CallBack_UserData; |
@@ -735,7 +707,8 @@ int DvppDecoder::sendPkt(aclvdecChannelDesc *vdecChannelDesc, AVPacket* pkt, uns | @@ -735,7 +707,8 @@ int DvppDecoder::sendPkt(aclvdecChannelDesc *vdecChannelDesc, AVPacket* pkt, uns | ||
735 | 707 | ||
736 | // 报错情形 | 708 | // 报错情形 |
737 | if(input_stream_desc){ | 709 | if(input_stream_desc){ |
738 | - CHECK_NOT_RETURN(acldvppDestroyStreamDesc(input_stream_desc), "acldvppDestroyStreamDesc failed"); | 710 | + ACL_CHECK_AND_ABORT(acldvppDestroyStreamDesc(input_stream_desc), "acldvppDestroyStreamDesc failed"); |
711 | + input_stream_desc = nullptr; | ||
739 | } | 712 | } |
740 | 713 | ||
741 | if (vdecOutputBuf){ | 714 | if (vdecOutputBuf){ |
@@ -744,7 +717,8 @@ int DvppDecoder::sendPkt(aclvdecChannelDesc *vdecChannelDesc, AVPacket* pkt, uns | @@ -744,7 +717,8 @@ int DvppDecoder::sendPkt(aclvdecChannelDesc *vdecChannelDesc, AVPacket* pkt, uns | ||
744 | } | 717 | } |
745 | 718 | ||
746 | if(output_pic_desc){ | 719 | if(output_pic_desc){ |
747 | - CHECK_NOT_RETURN(acldvppDestroyPicDesc(output_pic_desc), "acldvppDestroyPicDesc failed"); | 720 | + ACL_CHECK_AND_ABORT(acldvppDestroyPicDesc(output_pic_desc), "acldvppDestroyPicDesc failed"); |
721 | + output_pic_desc = nullptr; | ||
748 | } | 722 | } |
749 | 723 | ||
750 | return -1; | 724 | return -1; |
@@ -752,20 +726,14 @@ int DvppDecoder::sendPkt(aclvdecChannelDesc *vdecChannelDesc, AVPacket* pkt, uns | @@ -752,20 +726,14 @@ int DvppDecoder::sendPkt(aclvdecChannelDesc *vdecChannelDesc, AVPacket* pkt, uns | ||
752 | 726 | ||
753 | void DvppDecoder::doProcessReport(){ | 727 | void DvppDecoder::doProcessReport(){ |
754 | 728 | ||
755 | - aclError ret = aclrtSetDevice(m_dvpp_deviceId); | ||
756 | - if(ret != ACL_ERROR_NONE){ | ||
757 | - LOG_ERROR("[{}]-aclrtSetDevice failed !", m_dec_name); | ||
758 | - return; | ||
759 | - } | 729 | + ACL_CHECK_AND_ABORT(aclrtSetDevice(m_dvpp_deviceId), "aclrtSetDevice failed"); |
760 | 730 | ||
761 | while (!m_bExitReportThd) { | 731 | while (!m_bExitReportThd) { |
762 | aclrtProcessReport(1000); | 732 | aclrtProcessReport(1000); |
763 | } | 733 | } |
764 | 734 | ||
765 | - ret = aclrtResetDevice(m_dvpp_deviceId); | ||
766 | - if(ret != ACL_ERROR_NONE){ | ||
767 | - LOG_ERROR("aclrtDestroyContext failed !"); | ||
768 | - } | 735 | + ACL_CHECK_AND_ABORT(aclrtResetDevice(m_dvpp_deviceId), "aclrtResetDevice failed"); |
736 | + | ||
769 | LOG_INFO("doProcessReport exit."); | 737 | LOG_INFO("doProcessReport exit."); |
770 | } | 738 | } |
771 | 739 | ||
@@ -783,7 +751,7 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o | @@ -783,7 +751,7 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o | ||
783 | 751 | ||
784 | m_out_count++; | 752 | m_out_count++; |
785 | 753 | ||
786 | - CHECK_AND_RETURN_NOVALUE(aclrtSetCurrentContext(m_context), "aclrtSetCurrentContext failed"); | 754 | + ACL_CHECK_AND_ABORT(aclrtSetCurrentContext(m_context), "aclrtSetCurrentContext failed"); |
787 | 755 | ||
788 | void *inputDataDev = acldvppGetStreamDescData(input); | 756 | void *inputDataDev = acldvppGetStreamDescData(input); |
789 | acldvppFree(inputDataDev); | 757 | acldvppFree(inputDataDev); |
@@ -797,13 +765,7 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o | @@ -797,13 +765,7 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o | ||
797 | uint32_t height_stride = acldvppGetPicDescHeightStride(output); | 765 | uint32_t height_stride = acldvppGetPicDescHeightStride(output); |
798 | 766 | ||
799 | do{ | 767 | do{ |
800 | - int ret = acldvppGetPicDescRetCode(output); | ||
801 | - if(ret != ACL_ERROR_NONE){ | ||
802 | - LOG_ERROR("[{}]- decode result error, retCode:{} ", m_dec_name, ret); | ||
803 | - acldvppFree(outputDataDev); | ||
804 | - outputDataDev = nullptr; | ||
805 | - break; | ||
806 | - } | 768 | + ACL_CHECK_AND_ABORT(acldvppGetPicDescRetCode(output), "acldvppGetPicDescRetCode failed"); |
807 | 769 | ||
808 | bool bCached = false; | 770 | bool bCached = false; |
809 | if(width > 0 && height > 0 && outputSize > 0){ | 771 | if(width > 0 && height > 0 && outputSize > 0){ |
@@ -828,16 +790,20 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o | @@ -828,16 +790,20 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o | ||
828 | // 换成解码后数据, 这里这样做的是为了保证解码一直持续进行,避免后续操作阻碍文件读取和解码从而导致花屏 | 790 | // 换成解码后数据, 这里这样做的是为了保证解码一直持续进行,避免后续操作阻碍文件读取和解码从而导致花屏 |
829 | DvppDataMemory* mem = nullptr; | 791 | DvppDataMemory* mem = nullptr; |
830 | if (m_bResize && (width > 1920 || height > 1080)) { | 792 | if (m_bResize && (width > 1920 || height > 1080)) { |
831 | - | ||
832 | - mem = m_vpcUtils.resize(output, out_frame_width, out_frame_height); | ||
833 | - if (mem) { | ||
834 | - acldvppFree(outputDataDev); | ||
835 | - outputDataDev = nullptr; | ||
836 | - | ||
837 | - mem->setDeviceId(to_string(m_dvpp_deviceId)); | ||
838 | - mem->setId(m_dec_name); | ||
839 | - mem->setFrameNb(frame_nb); | 793 | + VpcUtils* pUtil = VpcUtils::getInstance(); |
794 | + if (pUtil) { | ||
795 | + mem = pUtil->resize(output, out_frame_width, out_frame_height); | ||
796 | + if (mem) { | ||
797 | + acldvppFree(outputDataDev); | ||
798 | + outputDataDev = nullptr; | ||
799 | + | ||
800 | + mem->setDeviceId(to_string(m_dvpp_deviceId)); | ||
801 | + mem->setId(m_dec_name); | ||
802 | + mem->setFrameNb(frame_nb); | ||
803 | + } | ||
840 | } | 804 | } |
805 | + | ||
806 | + | ||
841 | } else { | 807 | } else { |
842 | mem = new DvppDataMemory(width, width_stride, height, height_stride, outputSize, m_dec_name, to_string(m_dvpp_deviceId), false, frame_nb, (unsigned char *)outputDataDev); | 808 | mem = new DvppDataMemory(width, width_stride, height, height_stride, outputSize, m_dec_name, to_string(m_dvpp_deviceId), false, frame_nb, (unsigned char *)outputDataDev); |
843 | } | 809 | } |
@@ -857,8 +823,8 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o | @@ -857,8 +823,8 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o | ||
857 | } | 823 | } |
858 | }while(0); | 824 | }while(0); |
859 | 825 | ||
860 | - CHECK_AND_RETURN_NOVALUE(acldvppDestroyStreamDesc(input), "acldvppDestroyStreamDesc failed"); | ||
861 | - CHECK_AND_RETURN_NOVALUE(acldvppDestroyPicDesc(output), "acldvppDestroyPicDesc failed"); | 826 | + ACL_CHECK_AND_ABORT(acldvppDestroyStreamDesc(input), "acldvppDestroyStreamDesc failed"); |
827 | + ACL_CHECK_AND_ABORT(acldvppDestroyPicDesc(output), "acldvppDestroyPicDesc failed"); | ||
862 | } | 828 | } |
863 | 829 | ||
864 | bool DvppDecoder::sendVdecEos(aclvdecChannelDesc *vdecChannelDesc) { | 830 | bool DvppDecoder::sendVdecEos(aclvdecChannelDesc *vdecChannelDesc) { |
@@ -931,10 +897,7 @@ void DvppDecoder::display_thread() { | @@ -931,10 +897,7 @@ void DvppDecoder::display_thread() { | ||
931 | 897 | ||
932 | void DvppDecoder::release_dvpp(){ | 898 | void DvppDecoder::release_dvpp(){ |
933 | if(m_context){ | 899 | if(m_context){ |
934 | - aclError ret = aclrtDestroyContext(m_context); | ||
935 | - if(ret != ACL_ERROR_NONE){ | ||
936 | - LOG_ERROR("[{}]- aclrtDestroyContext failed !", m_dec_name); | ||
937 | - } | 900 | + ACL_CHECK_AND_ABORT(aclrtDestroyContext(m_context), "aclrtDestroyContext failed"); |
938 | m_context = nullptr; | 901 | m_context = nullptr; |
939 | } | 902 | } |
940 | 903 |
src/decoder/dvpp/DvppDecoder.h
@@ -12,8 +12,6 @@ | @@ -12,8 +12,6 @@ | ||
12 | 12 | ||
13 | #include "FFRecoderTaskManager.h" | 13 | #include "FFRecoderTaskManager.h" |
14 | 14 | ||
15 | -#include "VpcUtils.h" | ||
16 | - | ||
17 | using namespace std; | 15 | using namespace std; |
18 | 16 | ||
19 | typedef void(*RECEIVER_FINISHED_CALLBACK)(const void* userPtr); | 17 | typedef void(*RECEIVER_FINISHED_CALLBACK)(const void* userPtr); |
@@ -143,6 +141,4 @@ private: | @@ -143,6 +141,4 @@ private: | ||
143 | 141 | ||
144 | std::atomic<int> m_DvppCacheCounter{0}; | 142 | std::atomic<int> m_DvppCacheCounter{0}; |
145 | int m_cache_gop{0}; | 143 | int m_cache_gop{0}; |
146 | - | ||
147 | - VpcUtils m_vpcUtils; | ||
148 | }; | 144 | }; |
149 | \ No newline at end of file | 145 | \ No newline at end of file |
src/decoder/dvpp/VpcUtils.cpp
@@ -3,14 +3,8 @@ | @@ -3,14 +3,8 @@ | ||
3 | 3 | ||
4 | #define ALIGN_UP(val, align) (((val) % (align) == 0) ? (val) : (((val) / (align) + 1) * (align))) | 4 | #define ALIGN_UP(val, align) (((val) % (align) == 0) ? (val) : (((val) / (align) + 1) * (align))) |
5 | 5 | ||
6 | -#define CHECK_AND_RETURN(ret, message) \ | ||
7 | - if(ret != 0) {LOG_ERROR("{}", message); return ret;} | ||
8 | -#define CHECK_NOT_RETURN(ret, message) \ | ||
9 | - if(ret != 0) {LOG_ERROR("{}", message);} | ||
10 | -#define CHECK_AND_RETURN_NOVALUE(ret, message) \ | ||
11 | - if(ret != 0) {LOG_ERROR("{}", message); return;} | ||
12 | -#define CHECK_AND_BREAK(ret, message) \ | ||
13 | - if(ret != 0) {LOG_ERROR("{}", message); break;} | 6 | +#define ACL_CHECK_AND_ABORT(ret, message) \ |
7 | + if(ret != 0) {LOG_ERROR("{}", message); std::abort();} | ||
14 | 8 | ||
15 | VpcUtils::VpcUtils(){ | 9 | VpcUtils::VpcUtils(){ |
16 | 10 | ||
@@ -22,34 +16,33 @@ VpcUtils::~VpcUtils(){ | @@ -22,34 +16,33 @@ VpcUtils::~VpcUtils(){ | ||
22 | 16 | ||
23 | int VpcUtils::init(int devId){ | 17 | int VpcUtils::init(int devId){ |
24 | 18 | ||
19 | + if (context_) { | ||
20 | + return 1; | ||
21 | + } | ||
22 | + | ||
23 | + | ||
25 | m_devId = devId; | 24 | m_devId = devId; |
26 | 25 | ||
27 | - aclError ret = aclrtCreateContext(&context_, m_devId); | ||
28 | - if (ret != ACL_ERROR_NONE) { | ||
29 | - LOG_ERROR("[{}]-aclrtCreateContext failed !", m_dec_name); | ||
30 | - return false; | ||
31 | - } | 26 | + ACL_CHECK_AND_ABORT(aclrtCreateContext(&context_, m_devId), "aclrtCreateContext failed !"); |
32 | 27 | ||
33 | do | 28 | do |
34 | { | 29 | { |
35 | - aclrtCreateStream(&stream_); | 30 | + ACL_CHECK_AND_ABORT(aclrtCreateStream(&stream_), "aclrtCreateStream failed !"); |
36 | 31 | ||
37 | dvppChannelDesc_ = acldvppCreateChannelDesc(); | 32 | dvppChannelDesc_ = acldvppCreateChannelDesc(); |
38 | 33 | ||
39 | - ret = acldvppCreateChannel(dvppChannelDesc_); | ||
40 | - CHECK_AND_BREAK(ret, "acldvppCreateChannel failed !"); | ||
41 | - | ||
42 | - ret = acldvppSetChannelDescMode(dvppChannelDesc_, DVPP_CHNMODE_VPC); | ||
43 | - CHECK_AND_BREAK(ret, "acldvppSetChannelDescMode failed !"); | 34 | + ACL_CHECK_AND_ABORT(acldvppSetChannelDescMode(dvppChannelDesc_, DVPP_CHNMODE_VPC), "acldvppSetChannelDescMode failed !"); |
35 | + ACL_CHECK_AND_ABORT(acldvppCreateChannel(dvppChannelDesc_), "acldvppCreateChannel failed !"); | ||
36 | + | ||
44 | } while (0); | 37 | } while (0); |
45 | 38 | ||
46 | - return ret; | 39 | + return 0; |
47 | } | 40 | } |
48 | 41 | ||
49 | void VpcUtils::release() { | 42 | void VpcUtils::release() { |
50 | 43 | ||
51 | if(context_){ | 44 | if(context_){ |
52 | - aclrtSetCurrentContext(context_); | 45 | + ACL_CHECK_AND_ABORT(aclrtSetCurrentContext(context_), "aclrtSetCurrentContext failed !"); |
53 | 46 | ||
54 | if (dvppChannelDesc_) { | 47 | if (dvppChannelDesc_) { |
55 | (void)acldvppDestroyChannel(dvppChannelDesc_); | 48 | (void)acldvppDestroyChannel(dvppChannelDesc_); |
@@ -63,12 +56,13 @@ void VpcUtils::release() { | @@ -63,12 +56,13 @@ void VpcUtils::release() { | ||
63 | } | 56 | } |
64 | 57 | ||
65 | aclrtDestroyContext(context_); | 58 | aclrtDestroyContext(context_); |
59 | + context_ = nullptr; | ||
66 | } | 60 | } |
67 | } | 61 | } |
68 | 62 | ||
69 | DvppDataMemory* VpcUtils::convert2bgr(acldvppPicDesc *inputDesc_, int out_width, int out_height, bool key_frame){ | 63 | DvppDataMemory* VpcUtils::convert2bgr(acldvppPicDesc *inputDesc_, int out_width, int out_height, bool key_frame){ |
70 | 64 | ||
71 | - aclrtSetCurrentContext(context_); | 65 | + ACL_CHECK_AND_ABORT(aclrtSetCurrentContext(context_), "aclrtSetCurrentContext failed !"); |
72 | 66 | ||
73 | int out_buf_width = ALIGN_UP(out_width, 16) * 3; | 67 | int out_buf_width = ALIGN_UP(out_width, 16) * 3; |
74 | int out_buf_height = ALIGN_UP(out_height, 2); | 68 | int out_buf_height = ALIGN_UP(out_height, 2); |
@@ -78,6 +72,11 @@ DvppDataMemory* VpcUtils::convert2bgr(acldvppPicDesc *inputDesc_, int out_width, | @@ -78,6 +72,11 @@ DvppDataMemory* VpcUtils::convert2bgr(acldvppPicDesc *inputDesc_, int out_width, | ||
78 | void *outBufferDev_ = (void*)rgbMem->getMem(); | 72 | void *outBufferDev_ = (void*)rgbMem->getMem(); |
79 | 73 | ||
80 | acldvppPicDesc *outputDesc_= acldvppCreatePicDesc(); | 74 | acldvppPicDesc *outputDesc_= acldvppCreatePicDesc(); |
75 | + if(outputDesc_ == nullptr){ | ||
76 | + LOG_ERROR("acldvppCreatePicDesc failed !"); | ||
77 | + std::abort(); | ||
78 | + } | ||
79 | + | ||
81 | acldvppSetPicDescData(outputDesc_, outBufferDev_); | 80 | acldvppSetPicDescData(outputDesc_, outBufferDev_); |
82 | acldvppSetPicDescFormat(outputDesc_, PIXEL_FORMAT_BGR_888); | 81 | acldvppSetPicDescFormat(outputDesc_, PIXEL_FORMAT_BGR_888); |
83 | acldvppSetPicDescWidth(outputDesc_, out_width); | 82 | acldvppSetPicDescWidth(outputDesc_, out_width); |
@@ -92,12 +91,13 @@ DvppDataMemory* VpcUtils::convert2bgr(acldvppPicDesc *inputDesc_, int out_width, | @@ -92,12 +91,13 @@ DvppDataMemory* VpcUtils::convert2bgr(acldvppPicDesc *inputDesc_, int out_width, | ||
92 | ret = acldvppVpcConvertColorAsync(dvppChannelDesc_, inputDesc_, outputDesc_, stream_); | 91 | ret = acldvppVpcConvertColorAsync(dvppChannelDesc_, inputDesc_, outputDesc_, stream_); |
93 | if(ret != ACL_ERROR_NONE){ | 92 | if(ret != ACL_ERROR_NONE){ |
94 | LOG_ERROR("acldvppVpcConvertColorAsync failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); | 93 | LOG_ERROR("acldvppVpcConvertColorAsync failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); |
95 | - break; | 94 | + std::abort(); |
96 | } | 95 | } |
96 | + | ||
97 | ret = aclrtSynchronizeStream(stream_); | 97 | ret = aclrtSynchronizeStream(stream_); |
98 | if(ret != ACL_ERROR_NONE){ | 98 | if(ret != ACL_ERROR_NONE){ |
99 | LOG_ERROR("aclrtSynchronizeStream failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); | 99 | LOG_ERROR("aclrtSynchronizeStream failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); |
100 | - break; | 100 | + std::abort(); |
101 | } | 101 | } |
102 | }while(0); | 102 | }while(0); |
103 | 103 | ||
@@ -113,13 +113,18 @@ DvppDataMemory* VpcUtils::convert2bgr(acldvppPicDesc *inputDesc_, int out_width, | @@ -113,13 +113,18 @@ DvppDataMemory* VpcUtils::convert2bgr(acldvppPicDesc *inputDesc_, int out_width, | ||
113 | 113 | ||
114 | DvppDataMemory* VpcUtils::convert2bgr(DvppDataMemory* inMem){ | 114 | DvppDataMemory* VpcUtils::convert2bgr(DvppDataMemory* inMem){ |
115 | 115 | ||
116 | - aclrtSetCurrentContext(context_); | 116 | + ACL_CHECK_AND_ABORT(aclrtSetCurrentContext(context_), "aclrtSetCurrentContext failed !"); |
117 | 117 | ||
118 | int out_width = inMem->getWidth(); | 118 | int out_width = inMem->getWidth(); |
119 | int out_height = inMem->getHeight(); | 119 | int out_height = inMem->getHeight(); |
120 | 120 | ||
121 | 121 | ||
122 | acldvppPicDesc *inputDesc_= acldvppCreatePicDesc(); | 122 | acldvppPicDesc *inputDesc_= acldvppCreatePicDesc(); |
123 | + if(inputDesc_ == nullptr){ | ||
124 | + LOG_ERROR("acldvppCreatePicDesc failed !"); | ||
125 | + std::abort(); | ||
126 | + } | ||
127 | + | ||
123 | acldvppSetPicDescData(inputDesc_, inMem->getMem()); | 128 | acldvppSetPicDescData(inputDesc_, inMem->getMem()); |
124 | acldvppSetPicDescFormat(inputDesc_, PIXEL_FORMAT_YUV_SEMIPLANAR_420); | 129 | acldvppSetPicDescFormat(inputDesc_, PIXEL_FORMAT_YUV_SEMIPLANAR_420); |
125 | acldvppSetPicDescWidth(inputDesc_, out_width); | 130 | acldvppSetPicDescWidth(inputDesc_, out_width); |
@@ -136,6 +141,11 @@ DvppDataMemory* VpcUtils::convert2bgr(DvppDataMemory* inMem){ | @@ -136,6 +141,11 @@ DvppDataMemory* VpcUtils::convert2bgr(DvppDataMemory* inMem){ | ||
136 | void *outBufferDev_ = (void*)rgbMem->getMem(); | 141 | void *outBufferDev_ = (void*)rgbMem->getMem(); |
137 | 142 | ||
138 | acldvppPicDesc *outputDesc_= acldvppCreatePicDesc(); | 143 | acldvppPicDesc *outputDesc_= acldvppCreatePicDesc(); |
144 | + if(outputDesc_ == nullptr){ | ||
145 | + LOG_ERROR("acldvppCreatePicDesc failed !"); | ||
146 | + std::abort(); | ||
147 | + } | ||
148 | + | ||
139 | acldvppSetPicDescData(outputDesc_, outBufferDev_); | 149 | acldvppSetPicDescData(outputDesc_, outBufferDev_); |
140 | acldvppSetPicDescFormat(outputDesc_, PIXEL_FORMAT_BGR_888); | 150 | acldvppSetPicDescFormat(outputDesc_, PIXEL_FORMAT_BGR_888); |
141 | acldvppSetPicDescWidth(outputDesc_, out_width); | 151 | acldvppSetPicDescWidth(outputDesc_, out_width); |
@@ -150,12 +160,12 @@ DvppDataMemory* VpcUtils::convert2bgr(DvppDataMemory* inMem){ | @@ -150,12 +160,12 @@ DvppDataMemory* VpcUtils::convert2bgr(DvppDataMemory* inMem){ | ||
150 | ret = acldvppVpcConvertColorAsync(dvppChannelDesc_, inputDesc_, outputDesc_, stream_); | 160 | ret = acldvppVpcConvertColorAsync(dvppChannelDesc_, inputDesc_, outputDesc_, stream_); |
151 | if(ret != ACL_ERROR_NONE){ | 161 | if(ret != ACL_ERROR_NONE){ |
152 | LOG_ERROR("acldvppVpcConvertColorAsync failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); | 162 | LOG_ERROR("acldvppVpcConvertColorAsync failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); |
153 | - break; | 163 | + std::abort(); |
154 | } | 164 | } |
155 | ret = aclrtSynchronizeStream(stream_); | 165 | ret = aclrtSynchronizeStream(stream_); |
156 | if(ret != ACL_ERROR_NONE){ | 166 | if(ret != ACL_ERROR_NONE){ |
157 | LOG_ERROR("aclrtSynchronizeStream failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); | 167 | LOG_ERROR("aclrtSynchronizeStream failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); |
158 | - break; | 168 | + std::abort(); |
159 | } | 169 | } |
160 | }while(0); | 170 | }while(0); |
161 | 171 | ||
@@ -172,7 +182,7 @@ DvppDataMemory* VpcUtils::convert2bgr(DvppDataMemory* inMem){ | @@ -172,7 +182,7 @@ DvppDataMemory* VpcUtils::convert2bgr(DvppDataMemory* inMem){ | ||
172 | 182 | ||
173 | DvppDataMemory* VpcUtils::resize(acldvppPicDesc *inputDesc_, int out_width, int out_height){ | 183 | DvppDataMemory* VpcUtils::resize(acldvppPicDesc *inputDesc_, int out_width, int out_height){ |
174 | 184 | ||
175 | - aclrtSetCurrentContext(context_); | 185 | + ACL_CHECK_AND_ABORT(aclrtSetCurrentContext(context_), "aclrtSetCurrentContext failed !"); |
176 | 186 | ||
177 | int out_buf_width = ALIGN_UP(out_width, 16); | 187 | int out_buf_width = ALIGN_UP(out_width, 16); |
178 | int out_buf_height = ALIGN_UP(out_height, 2); | 188 | int out_buf_height = ALIGN_UP(out_height, 2); |
@@ -182,6 +192,10 @@ DvppDataMemory* VpcUtils::resize(acldvppPicDesc *inputDesc_, int out_width, int | @@ -182,6 +192,10 @@ DvppDataMemory* VpcUtils::resize(acldvppPicDesc *inputDesc_, int out_width, int | ||
182 | void *outBufferDev_ = (void*)rgbMem->getMem(); | 192 | void *outBufferDev_ = (void*)rgbMem->getMem(); |
183 | 193 | ||
184 | acldvppPicDesc *outputDesc_= acldvppCreatePicDesc(); | 194 | acldvppPicDesc *outputDesc_= acldvppCreatePicDesc(); |
195 | + if(outputDesc_ == nullptr){ | ||
196 | + LOG_ERROR("acldvppCreatePicDesc failed !"); | ||
197 | + std::abort(); | ||
198 | + } | ||
185 | acldvppSetPicDescData(outputDesc_, outBufferDev_); | 199 | acldvppSetPicDescData(outputDesc_, outBufferDev_); |
186 | acldvppSetPicDescFormat(outputDesc_, acldvppGetPicDescFormat(inputDesc_)); | 200 | acldvppSetPicDescFormat(outputDesc_, acldvppGetPicDescFormat(inputDesc_)); |
187 | acldvppSetPicDescWidth(outputDesc_, out_width); | 201 | acldvppSetPicDescWidth(outputDesc_, out_width); |
@@ -198,12 +212,12 @@ DvppDataMemory* VpcUtils::resize(acldvppPicDesc *inputDesc_, int out_width, int | @@ -198,12 +212,12 @@ DvppDataMemory* VpcUtils::resize(acldvppPicDesc *inputDesc_, int out_width, int | ||
198 | ret = acldvppVpcResizeAsync(dvppChannelDesc_, inputDesc_, outputDesc_, resizeConfig_, stream_); | 212 | ret = acldvppVpcResizeAsync(dvppChannelDesc_, inputDesc_, outputDesc_, resizeConfig_, stream_); |
199 | if(ret != ACL_ERROR_NONE){ | 213 | if(ret != ACL_ERROR_NONE){ |
200 | LOG_ERROR("acldvppVpcResizeAsync failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); | 214 | LOG_ERROR("acldvppVpcResizeAsync failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); |
201 | - break; | 215 | + std::abort(); |
202 | } | 216 | } |
203 | ret = aclrtSynchronizeStream(stream_); | 217 | ret = aclrtSynchronizeStream(stream_); |
204 | if(ret != ACL_ERROR_NONE){ | 218 | if(ret != ACL_ERROR_NONE){ |
205 | LOG_ERROR("aclrtSynchronizeStream failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); | 219 | LOG_ERROR("aclrtSynchronizeStream failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); |
206 | - break; | 220 | + std::abort(); |
207 | } | 221 | } |
208 | }while(0); | 222 | }while(0); |
209 | 223 |
src/decoder/dvpp/VpcUtils.h
@@ -5,8 +5,17 @@ | @@ -5,8 +5,17 @@ | ||
5 | 5 | ||
6 | class VpcUtils{ | 6 | class VpcUtils{ |
7 | public: | 7 | public: |
8 | + static VpcUtils* getInstance(){ | ||
9 | + static VpcUtils* singleton = nullptr; | ||
10 | + if (singleton == nullptr){ | ||
11 | + singleton = new VpcUtils(); | ||
12 | + } | ||
13 | + return singleton; | ||
14 | + } | ||
15 | + | ||
8 | VpcUtils(); | 16 | VpcUtils(); |
9 | ~VpcUtils(); | 17 | ~VpcUtils(); |
18 | + | ||
10 | int init(int); | 19 | int init(int); |
11 | 20 | ||
12 | DvppDataMemory* convert2bgr(acldvppPicDesc *input, int out_width, int out_height, bool key_frame); | 21 | DvppDataMemory* convert2bgr(acldvppPicDesc *input, int out_width, int out_height, bool key_frame); |
src/decoder/dvpp/dvpp_headers.h