⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simple_player.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* /////////////////////////////////////////////////////////////////////////////////                  INTEL CORPORATION PROPRIETARY INFORMATION//     This software is supplied under the terms of a license agreement or//     nondisclosure agreement with Intel Corporation and may not be copied//     or disclosed except in accordance with the terms of that agreement.//          Copyright(c) 2001-2005 Intel Corporation. All Rights Reserved.////              Intel(R) Integrated Performance Primitives//                  Video Coding (ippvc)//*/// simple_player.cpp : Defines the entry point for the console application.//#if defined (WIN32) || defined (WIN64)#include <conio.h>#endif // WIN32#include <stdio.h>#include <stdarg.h>#include <ippi.h>#include <ippcore.h>#include "vm_debug.h"#include "vm_time.h"#include "vm_sys_info.h"#include "umc_sys_info.h"#include "avsync.h"#include "codec_pipeline.h"#if defined(ARM) || defined(_ARM_)const unsigned int     cuiDisplayWidth  = 640;const unsigned int     cuiDisplayHeight = 480;const UMC::ColorFormat cDispColorFormat = UMC::RGB565;#else // defined(ARM) || defined(_ARM_)const unsigned int     cuiDisplayWidth  = 800;const unsigned int     cuiDisplayHeight = 600;const UMC::ColorFormat cDispColorFormat = UMC::YV12;#endif // defined(ARM) || defined(_ARM_)const unsigned long culReduceCoeff = UMC::FLAG_CCNV_CONVERT;//double cpu_use = 0;void PerfToFile(AVSync& rAVSync,                 AVSync::CommonCtl& r_cc,                 UMC :: SysInfo& m_csysinfo,                 vm_char* m_sz_curr_filename,                 vm_char* m_sz_perf_filename,                 int iFlag){    vm_char tmpbuf[128]={0,};    FILE* perf_file;    AVSync::Stat Stat;    vm_char* stream_name = NULL;    //UMC :: SysInfo m_csysinfo;    UMC :: sSystemInfo* m_ssysteminfo;    m_ssysteminfo = (UMC::sSystemInfo *)m_csysinfo.GetSysInfo();    switch(iFlag)    {    case 0:        perf_file = vm_file_open(m_sz_perf_filename, VM_STRING("a"));        if(perf_file){            stream_name = vm_string_strrchr(m_sz_curr_filename, (int)('\\'));            if(!stream_name)stream_name = m_sz_curr_filename;            else stream_name++;            fseek( perf_file, 0, SEEK_END);            if(!ftell( perf_file))                vm_string_fprintf(perf_file, VM_STRING("Date,Time,Comp.name,OS,CPU,Num.CPU,CPU freq.,MEM,VGA,App,App description,Ver.,Streams(S) name,Status,S.Type,S.Res.,S.FR,S.BR,Video(V)Type,V.Format,V.Num,V.D/E(FpS),V.D/E(MHz),V.RR(Fps),V.S(F),Audio(A)Type,A.Freq.,A.NC,A.(BpS),A.BR,A.D/E(MHz),CPU Usage (%%),Max Cpu Usage (%%),Work.Time\n"));            vm_sys_info_get_date(tmpbuf,MMDDYY);            vm_string_fprintf(perf_file,VM_STRING("%s,"), tmpbuf);            vm_sys_info_get_time(tmpbuf,HHMMSS);            vm_string_fprintf(perf_file,VM_STRING("%s,"), tmpbuf);            vm_string_fprintf(perf_file,VM_STRING("%s,"), m_ssysteminfo->computer_name);            vm_string_fprintf(perf_file,VM_STRING("%s,"), m_ssysteminfo->os_name);            vm_string_fprintf(perf_file,VM_STRING("%s,"), m_ssysteminfo->proc_name);            vm_string_fprintf(perf_file,VM_STRING("%d,"), m_ssysteminfo->num_proc);            vm_string_fprintf(perf_file,VM_STRING("%.2f,"), (double)m_ssysteminfo->cpu_freq);            vm_string_fprintf(perf_file,VM_STRING("%d,"), m_ssysteminfo->phys_mem);            vm_string_fprintf(perf_file,VM_STRING("%s,"), m_ssysteminfo->video_card);            vm_string_fprintf(perf_file,VM_STRING("%s,"),m_ssysteminfo->program_name);            vm_string_fprintf(perf_file,VM_STRING("UMC Simple Player,"));//,m_ssysteminfo->description);            vm_string_fprintf(perf_file,VM_STRING(","));        // ver. of aplications            vm_string_fprintf(perf_file,VM_STRING("%s,"), stream_name);            vm_string_fprintf(perf_file,VM_STRING("FAIL\n"));            fclose(perf_file);        }        break;    case 1:        perf_file = vm_file_open(m_sz_perf_filename, VM_STRING("r+"));        if(perf_file) {            fseek( perf_file, -6, SEEK_END);            vm_string_fprintf(perf_file,VM_STRING("PASSED,"));            UMC::Status umcRes = rAVSync.GetStat(Stat);            vm_string_fprintf(perf_file,VM_STRING("%s,"), UMC::GetStreamTypeString(rAVSync.GetSystemStreamType()));            vm_string_fprintf(perf_file,VM_STRING("%dx%d,"),rAVSync.GetSrcFrmWidth(),rAVSync.GetSrcFrmHeight());            vm_string_fprintf(perf_file,VM_STRING("%.2lf,"),(rAVSync.GetSrcFrmRate() ? rAVSync.GetSrcFrmRate() : 30.));            vm_string_fprintf(perf_file,VM_STRING("%d,"),rAVSync.GetSrcFrmBitRate());            vm_string_fprintf(perf_file,VM_STRING("%s,"), UMC::GetVideoTypeString(rAVSync.GetVideoStreamType()));            vm_string_fprintf(perf_file,VM_STRING("%s,"), UMC::GetFormatTypeString(rAVSync.GetVideoFormatType()));            vm_string_fprintf(perf_file,VM_STRING("%d,"), Stat.uiFrameNum);            vm_string_fprintf(perf_file,VM_STRING("%.2lf,"), Stat.dfDecodeRate);            if(Stat.dfDecodeRate)                vm_string_fprintf(perf_file,VM_STRING("%.2lf,"), rAVSync.GetSrcFrmRate()?(double)(rAVSync.GetSrcFrmRate()/Stat.dfDecodeRate*(m_ssysteminfo->cpu_freq)):(30./Stat.dfDecodeRate*(m_ssysteminfo->cpu_freq)));            else                vm_string_fprintf(perf_file,VM_STRING("%.2lf,"), 0.0);            if(Stat.dfRenderTime)                vm_string_fprintf(perf_file,VM_STRING("%.2lf,"), (double)(Stat.uiFrameNum/Stat.dfRenderTime));            else                vm_string_fprintf(perf_file,VM_STRING("%.2lf,"), 0.0);            vm_string_fprintf(perf_file,VM_STRING("%d,"), Stat.uiSkippedNum);            vm_string_fprintf(perf_file,VM_STRING("%s,"), UMC::GetAudioTypeString(rAVSync.GetAudioStreamType()));            vm_string_fprintf(perf_file,VM_STRING("%d,"), rAVSync.GetAudioSmplFreq());            vm_string_fprintf(perf_file,VM_STRING("%d,"), rAVSync.GetAudioNChannel());            vm_string_fprintf(perf_file,VM_STRING("%d,"), rAVSync.GetAudioBitPerSmpl());            vm_string_fprintf(perf_file,VM_STRING("%d,"), rAVSync.GetAudioBitRate());            //if((int)Stat.dfAudioDecodeRate)                vm_string_fprintf(perf_file,VM_STRING("%.2lf,"), Stat.dfAudioDecodeRate*m_ssysteminfo->cpu_freq);            //else            //    vm_string_fprintf(perf_file,VM_STRING("%.2lf,"), 0.0);            vm_string_fprintf(perf_file,VM_STRING("%.2lf,"), m_csysinfo.GetAvgCpuUsage());            vm_string_fprintf(perf_file,VM_STRING("%.2lf,"), m_csysinfo.GetMaxCpuUsage());            vm_string_fprintf(perf_file,VM_STRING("%02d:%02d:%02d,"),(int)Stat.dfRenderTime/3600,(int)(Stat.dfRenderTime)%3600/60,(int)Stat.dfRenderTime%3600%60);            vm_string_fprintf(perf_file,VM_STRING("\n" ));            fclose(perf_file);        }        break;    default:        break;    }}UMC::StatusAddPerfRecord(vm_char* szProfFileName,          vm_char* szMessage,          ...){    UMC::Status umcRes = UMC::UMC_OK;    FILE* pFile = NULL;    if (NULL != szProfFileName && 0 != szProfFileName[0])    {   pFile = vm_file_open(szProfFileName, VM_STRING("a+t"));  }    if (NULL != pFile)    {        va_list vl;        va_start( vl, szMessage );        vm_string_vfprintf(pFile, szMessage, vl);        va_end(vl);    }    if (NULL != pFile)    {   fclose(pFile);  }    return umcRes;}UMC::StatusPlaySingleFile(AVSync& rAVSync,               AVSync::CommonCtl& r_cc,               vm_char* szFileName,               vm_char* szProfFileName,               vm_var32 uiIterateNum,               vm_char* pcStopFlag){    UMC::Status umcRes = UMC::UMC_OK;    UMC :: SysInfo m_csysinfo;    assert(0 < uiIterateNum);    UMC::LocalReaderContext   readContext;    vm_string_strcpy(readContext.m_szFileName, szFileName);    r_cc.pReadContext = &readContext;    if (UMC::UMC_OK == umcRes &&        NULL != szProfFileName &&        0 != szProfFileName[0])    {        if (vm_string_strcmp(VM_STRING(".csv"),                             szProfFileName +                             (vm_string_strrchr(szProfFileName,                                                (vm_char)('.')) -                             szProfFileName)))        {            umcRes =                AddPerfRecord(szProfFileName,                              VM_STRING("Stream %s, %d iterations:\n"),                              szFileName,                              uiIterateNum);        }else{            PerfToFile(rAVSync,r_cc,m_csysinfo,szFileName,szProfFileName,0);        }    }    vm_var32 uiFrameNum = 0;    double dfDecodeTime = 0.0;    double dfRenderTime = 0.0;    double dfAudioDecTime = 0.0;    double dfAudioTime = 0.0;    for (vm_var32 uiTeration = 0;         UMC::UMC_OK == umcRes && uiTeration < uiIterateNum;         uiTeration++)    {        AVSync::Stat Stat;        umcRes = rAVSync.Init(r_cc);        r_cc.rectDisp.bottom = rAVSync.GetDstFrmHeight();        r_cc.rectDisp.right  = rAVSync.GetDstFrmWidth();        r_cc.rectRange.bottom = rAVSync.GetDstFrmHeight();        r_cc.rectRange.right  = rAVSync.GetDstFrmWidth();        rAVSync.ResizeDisplay(r_cc.rectDisp,r_cc.rectRange);        m_csysinfo.GetCpuUsage();        if (UMC::UMC_OK == umcRes)        {   umcRes = rAVSync.Start();    }        vm_var32 i = 0;        while (UMC::UMC_OK == umcRes && rAVSync.IsPlaying())        {#if defined(WIN32)#   if defined(_WIN32_WCE)            if (0 == *pcStopFlag)#   else // defined(_WIN32_WCE)            if (kbhit())#   endif // defined(_WIN32_WCE)            {   umcRes = rAVSync.Stop();    }            else#endif // defined(WIN32) && !defined(_WIN32_WCE)            {                umcRes = rAVSync.GetStat(Stat);//                if (i >= 100) {                if (i < Stat.uiFramesDecoded)                {                    if (UMC::UMC_OK == umcRes)                    {                        double dfDecTime = (Stat.dfDecodeRate) ? 1000/Stat.dfDecodeRate : 0;                        double dfConvertTime = (Stat.dfConversionRate) ? 1000/Stat.dfConversionRate : 0;                        //vm_debug_trace(-1,                        vm_string_printf( VM_STRING("DecRate:%.2f fps(Dec %.2fms/f + Conv %.2fms/f = %.2fms/f) RndrRate %.2ffps Audio Dec %.2fchnls \r\n"),                            Stat.dfDecodeRate,                            dfDecTime - dfConvertTime,                            dfConvertTime,                            dfDecTime,                            Stat.dfRenderRate,                            (Stat.dfAudioDecodeTime) ? Stat.dfAudioPlayTime/Stat.dfAudioDecodeTime : 0);                    }//                    i = 0;                    i += 100;                }//                i++;                vm_time_sleep(300/*500*/);                m_csysinfo.GetCpuUsage();            }        }        m_csysinfo.GetCpuUsage();        if (UMC::UMC_OK == umcRes &&            NULL != szProfFileName &&            0 != szProfFileName[0])        {            umcRes = rAVSync.GetStat(Stat);            uiFrameNum += Stat.uiFramesDecoded;            dfDecodeTime += Stat.dfDecodeTime;            dfRenderTime += Stat.dfRenderTime;            dfAudioDecTime += Stat.dfAudioDecodeTime;            dfAudioTime += Stat.dfAudioPlayTime;        }    }    if (UMC::UMC_OK == umcRes &&        NULL != szProfFileName &&        0 != szProfFileName[0])    {        if(vm_string_strcmp(VM_STRING(".csv"),szProfFileName+(vm_string_strrchr(szProfFileName, (vm_char)('.')) - szProfFileName)))            AddPerfRecord(szProfFileName,                          VM_STRING("DecRate: %.2f fps(%.2f ms/f) Rndr rate %.2f fps Audio Dec %.2f chnls\n\n"),                          (dfDecodeTime) ? (double)uiFrameNum / dfDecodeTime : 0,                          (uiFrameNum) ? dfDecodeTime * 1000 / uiFrameNum : 0,                          (dfRenderTime) ? (double)uiFrameNum / dfRenderTime : 0,                          (dfAudioDecTime) ? dfAudioTime / dfAudioDecTime : 0);        else PerfToFile(rAVSync,r_cc,m_csysinfo,szFileName,szProfFileName,1);    }    rAVSync.Stop();    return umcRes;}UMC::StatusPlayListFromFile(AVSync& rAVSync,                 AVSync::CommonCtl& r_cc,                 vm_char* szListFileName,                 vm_char* szProfFileName,                 vm_var32 iIterateNum,                 vm_char* pcStopFlag){    UMC::Status umcRes = UMC::UMC_OK;    FILE* pFileList = vm_file_open(szListFileName, VM_STRING("rt"));    vm_char szFileName[UMC::MAXIMUM_PATH];    if (NULL == pFileList) {    umcRes = UMC::UMC_BAD_STREAM;   }    // Clear perfomance log file    if (UMC::UMC_OK == umcRes &&        NULL != szProfFileName &&        0 != szProfFileName[0])    {        if(vm_string_strcmp(VM_STRING(".csv"),szProfFileName+(vm_string_strrchr(szProfFileName, (vm_char)('.')) - szProfFileName))) {            FILE* pProfFile = vm_file_open(szProfFileName, VM_STRING("wt"));            if (NULL != pProfFile)            {   fclose(pProfFile);  }            else {                vm_message(VM_STRING("Error!Failed to create perfomance log %s\n"),                           szProfFileName);                umcRes = UMC::UMC_FAILED_TO_INITIALIZE;            }        }    }    while (UMC::UMC_OK == umcRes && !feof(pFileList)) {        vm_char* szRes = vm_file_gets(szFileName, UMC::MAXIMUM_PATH, pFileList);        if (NULL != szRes) {            //  cut off New Line character (0x0A)            if (0xA == szFileName[vm_string_strlen(szFileName) - 1])            {   szFileName[vm_string_strlen(szFileName) - 1] = 0;  }            umcRes = PlaySingleFile(rAVSync,                                    r_cc,                                    szFileName,                                    szProfFileName,                                    iIterateNum,                                    pcStopFlag);        }    }    if (NULL != pFileList)    {   fclose(pFileList);  }    return umcRes;}voidPrintHelp(vm_char* szProgName){    assert(NULL != szProgName);    vm_char szMessage[] =        VM_STRING("Usage: %s [-s(ilent)][-b(lind)][-n(atural temp)][-p <perfomance log file name>][-i <iterations number>](-l <stream list file name>|stream)\n -f <yv12, yuy2, rgb565> -v <dx, gdi, gx,sdl, nul, fw> \n -a <dsound, nul, winmm, fw>");    vm_message(szMessage, szProgName);}intFileNameFromParams(int argc,                   vm_char** argv,                   int iFirstParam,                   vm_char* szFileName)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -