📄 simple_player.cpp
字号:
return umcRes;
}
UMC::Status PlayListFromFile(AVSync& rAVSync,
AVSync::CommonCtl& r_cc,
vm_char* szListFileName,
vm_char* szProfFileName,
Ipp32u iIterateNum,
vm_char* pcStopFlag)
{
UMC::Status umcRes = UMC::UMC_OK;
vm_file* pFileList = vm_file_open(szListFileName, VM_STRING("rt"));
vm_char szFileName[UMC::MAXIMUM_PATH];
if (NULL == pFileList) { umcRes = UMC::UMC_ERR_INVALID_STREAM; }
// Clear performance 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))) {
vm_file* pProfFile = vm_file_open(szProfFileName, VM_STRING("wt"));
if (NULL != pProfFile)
{ vm_file_fclose(pProfFile); }
else {
vm_debug_message(VM_STRING("Error!Failed to create performance log %s\n"),
szProfFileName);
umcRes = UMC::UMC_ERR_INIT;
}
}
}
while (UMC::UMC_OK == umcRes && !vm_file_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)
{ vm_file_fclose(pFileList); }
return umcRes;
}
void PrintHelp(vm_char* szProgName)
{
VM_ASSERT(NULL != szProgName);
vm_char szMessage[] =
VM_STRING("Usage: %s \n\
[-s(ilent)]\n\
[-b(lind)]\n\
[-n(atural temp)]\n\
[-u(nrendered audio)\n\
[-d(einterlacing)\n\
[-i <number of iterations>\n\
[-t<number of threads for decoding>\n\
[-p <perfomance log file name> (must be in quotes if it contains gaps)]\n\
[-v<%s, nul, fw, fwf> <output video file name>\n\
-in the case of -vfwf>]\n\
[-a<%s, nul, fw, fwf> <output audio file name>\n\
-in the case of -afwf]\n\
[-f<yv12, yuv420, yuv422, yuy2, rgb565, rgb24, def>]\n\
(-l <stream list file name>|stream>(must be in quotes if it contains gaps)\n");
vm_char szVideoRenderList [] =
#if defined(WIN32)
VM_STRING("gdi, dx, blt");
#endif
#if (defined (_WIN32_WCE) && (defined(x86) || defined(_X86_))) || (defined (WIN64))
VM_STRING("gdi");
#endif
#if defined(LINUX32) && !(defined (_ARM_) || defined(ARM))
#ifdef OSX32
VM_STRING("agl");
#else
VM_STRING("fb, sdl");
#endif
#endif
#if defined(LINUX32) && (defined (ARM) || defined(_ARM_))
VM_STRING("fb");
#endif
vm_char szAudioRenderList [] =
#if defined(WIN32)
VM_STRING("winmm, dsound");
#endif
#if (defined(_WIN32_WCE) && (defined(x86) || defined(_X86_))) || defined (WIN64) || defined(_WIN32_WCE) && (defined (ARM) || defined(_ARM_))
VM_STRING("winmm");
#endif
#if defined(LINUX32) && !(defined (_ARM_) || defined(ARM))
#ifdef OSX32
VM_STRING("coreaudio");
#else
VM_STRING("alsa, oss, sdl");
#endif
#endif
#if defined(LINUX32) && (defined (ARM) || defined(_ARM_))
VM_STRING("alsa, oss");
#endif
vm_string_printf(szMessage, szProgName, szVideoRenderList, szAudioRenderList);
}
Ipp32s FileNameFromParams(Ipp32s argc,
vm_char** argv,
Ipp32s iFirstParam,
vm_char* szFileName)
{
bool bQuotes = false;
VM_ASSERT(0 == szFileName[0]);
if ('"' == argv[iFirstParam][0])
{
bQuotes = true;
argv[iFirstParam]++;
}
vm_string_strcat(szFileName, argv[iFirstParam++]);
if (bQuotes)
{
for(;;)
{
Ipp32u uiLen = vm_string_strlen(szFileName);
if (0 < uiLen && '"' == szFileName[uiLen - 1])
{
szFileName[uiLen - 1] = 0;
break;
}
else
{
if(argc > iFirstParam /*&& '-' != argv[iFirstParam][0]*/)
{
if('"' == argv[iFirstParam][0])
{
break;
}
vm_string_strcat(szFileName, VM_STRING(" "));
vm_string_strcat(szFileName, argv[iFirstParam++]);
}
else
{
break;
}
}
}//for(;;)
}
return --iFirstParam;
}
extern "C" void vm_get_cpu_tick_init();
extern "C" Ipp32u vm_get_cpu_tick();
#if defined (WIN32) && !defined(_WIN32_WCE)
void GetClientRect(HWND hWnd, UMC::RECT& rDispRect, UMC::RECT& rRangeRect)
{
POINT pt = {0,0};
::ClientToScreen(hWnd, &pt);
::RECT rect;
::GetClientRect(hWnd, &rect);
UMC::Rect2UMCRect(rect, rDispRect);
rDispRect.left += (Ipp16s)pt.x;
rDispRect.right += (Ipp16s)pt.x;
rDispRect.top += (Ipp16s)(pt.y + 0);
rDispRect.bottom += (Ipp16s)(pt.y - 0 - 0);
::SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
UMC::Rect2UMCRect(rect, rRangeRect);
}
#endif
int main(Ipp32s argc, vm_char* argv[])
{
UMC::Status umcRes = UMC::UMC_OK;
AVSync AVSync;
AVSync::CommonCtl cc;
#if !defined(ARM) && !defined(_ARM_)
ippStaticInit();
#endif // !defined(ARM) && !defined(_ARM_)
cc.cformat = cDispColorFormat;
cc.ulReduceCoeff = UMC::FLAG_CCNV_CONVERT;
cc.ulSplitterFlags = //UMC::FLAG_VSPL_VIDEO_HEADER_REQ |
UMC::AUDIO_SPLITTER |
UMC::VIDEO_SPLITTER;
cc.ulVideoDecoderFlags = UMC::FLAG_VDEC_REORDER;
cc.ulVideoRenderFlags = 0;
//cc.ulVideoRenderFlags = UMC::FLAG_VREN_REORDER;
cc.ulReduceCoeff = 0 | UMC::FLAG_CCNV_CONVERT;
cc.lInterpolation = IPPI_INTER_NN;
cc.ulAudioDecoderFlags = 0;
cc.ulAudioRenderFlags = 0;
cc.uiPrefVideoRender = 0;
cc.uiPrefAudioRender = 0;
cc.uiPrefDataReader = 0;
cc.pExternalInfo = NULL;
cc.terminate = false;
cc.performance = false;
cc.repeat = false;
cc.fullscr = false;
cc.stick = true;
cc.debug = true;
cc.bSync = true;
cc.step = false;
cc.uiLimitVideoDecodeThreads = 0; //auto threading
#ifdef WIN32
UMC::HWNDModuleContext Context;
POINT Point = {0, 0};
Context.m_hWnd = ::WindowFromPoint(Point);
Context.m_ColorKey = RGB(0,0,0);
#endif // defined(WIN32)
#ifdef LINUX32
UMC::ModuleContext Context;
#endif // LINUX32
cc.pRenContext = &Context;
cc.rectDisp.left = 0;
cc.rectDisp.top = 0;
cc.rectDisp.right = cuiDisplayWidth;
cc.rectDisp.bottom = cuiDisplayHeight;
cc.uiPrefVideoRender = UMC::DEF_VIDEO_RENDER;
cc.uiPrefAudioRender = UMC::DEF_AUDIO_RENDER;
#if defined (WIN32) && !defined(_WIN32_WCE)
GetClientRect(Context.m_hWnd,cc.rectDisp,cc.rectRange);
#endif // defined(WIN32)
vm_char szFileName[UMC::MAXIMUM_PATH] = VM_STRING("");
vm_char szPerfLogFileName[UMC::MAXIMUM_PATH] = VM_STRING("");
Ipp32u uiIterations = 1;
bool bPlayFromList = false;
Ipp32s i = 1;
while (UMC::UMC_OK == umcRes && i < argc)
{
size_t stArgLen = vm_string_strlen(argv[i]);
if ('-' == argv[i][0]) {
switch (argv[i][1]) {
case 'l':
case 'L':
if (2 == stArgLen)
{
if ((i+1) < argc)
i = FileNameFromParams(argc, argv, ++i, szFileName);
else {
vm_debug_message(VM_STRING("Error! Wrong usage of key (-L). Name of list-file is absent!\n"));
umcRes = UMC::UMC_ERR_INIT;
}
} else {
argv[i] += 2;
i = FileNameFromParams(argc, argv, i, szFileName);
}
bPlayFromList = true;
break;
case 'p':
case 'P':
if (2 == stArgLen)
{
if ((i+1) < argc)
i = FileNameFromParams(argc, argv, ++i, szPerfLogFileName);
else {
vm_debug_message(VM_STRING("Error! Wrong usage of key (-p). Name of logfile is absent!\n"));
umcRes = UMC::UMC_ERR_INIT;
}
} else {
argv[i] += 2;
i = FileNameFromParams(argc, argv, i, szPerfLogFileName);
}
break;
case 'i':
case 'I':
if (2 == stArgLen) {
i++;
if (i < argc)
uiIterations = vm_string_atol(argv[i]);
else {
vm_debug_message(VM_STRING("Error! Wrong usage of key (-i). Number of iterations is absent!\n"));
umcRes = UMC::UMC_ERR_INIT;
}
} else {
uiIterations = vm_string_atol(argv[i] + 2);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -