📄 simple_player.cpp
字号:
{ bool bQuotes = false; assert(0 == szFileName[0]); if ('"' == argv[iFirstParam][0]) { bQuotes = true; argv[iFirstParam]++; } vm_string_strcat(szFileName, argv[iFirstParam++]); while (argc > iFirstParam && '-' != argv[iFirstParam][0]) { if (bQuotes) { vm_var32 uiLen = vm_string_strlen(szFileName); if (0 < uiLen && '"' == szFileName[uiLen - 1]) { szFileName[uiLen - 1] = 0; break; } } if ('"' == argv[iFirstParam][0]) { break; } vm_string_strcat(szFileName, VM_STRING(" ")); vm_string_strcat(szFileName, argv[iFirstParam++]); } if (bQuotes) { vm_var32 uiLen = vm_string_strlen(szFileName); if (0 < uiLen && '"' == szFileName[uiLen - 1]) { szFileName[uiLen - 1] = 0; } } return --iFirstParam;}extern "C" void vm_get_cpu_tick_init();extern "C" unsigned int 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 += (short)pt.x; rDispRect.right += (short)pt.x; rDispRect.top += (short)(pt.y + 0); rDispRect.bottom += (short)(pt.y - 0 - 0); ::SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0); UMC::Rect2UMCRect(rect, rRangeRect);}#endifint main(int 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::FLAG_VSPL_COMPATIBLE | UMC::VIDEO_SPLITTER; cc.ulVideoDecoderFlags = UMC::FLAG_VDEC_NO_PREVIEW | UMC::FLAG_VDEC_COMPATIBLE; cc.ulVideoRenderFlags = UMC::FLAG_VREN_REORDER;#if !defined(ARM) && !defined(_ARM_)// cc.ulVideoDecoderFlags |= UMC::FLAG_VDEC_UVMERGED;#endif // !defined(ARM) && !defined(_ARM_) 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 = false; 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(""); vm_var32 uiIterations = 1; bool bPlayFromList = false; int 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_message(VM_STRING("Error! Wrong usage of key (-L). Name of list-file is absent!\n")); umcRes = UMC::UMC_FAILED_TO_INITIALIZE; } } 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_message(VM_STRING("Error! Wrong usage of key (-p). Name of logfile is absent!\n")); umcRes = UMC::UMC_FAILED_TO_INITIALIZE; } } 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_message(VM_STRING("Error! Wrong usage of key (-i). Number of iterations is absent!\n")); umcRes = UMC::UMC_FAILED_TO_INITIALIZE; } } else { uiIterations = vm_string_atol(argv[i] + 2); } if (0 == uiIterations) { vm_message(VM_STRING("Error! Wrong iteration number (-i) parameter!\n")); umcRes = UMC::UMC_FAILED_TO_INITIALIZE; } break; case 's': case 'S': // Turn sound off cc.ulSplitterFlags &= ~UMC::AUDIO_SPLITTER; break; case 'b': case 'B': // Turn off color conversion and displaying - decoding only cc.ulReduceCoeff = 0; break; case 'n': case 'N': // Play synchronously (in real time) even if // sound is turned off cc.bSync = true; break; case 'u': case 'U': // Decode audio but don't render it cc.ulAudioRenderFlags |= UMC::FLAG_AREN_VOID; break; case 'a': case 'A': { vm_char* szCode = NULL; // Use predefined audio render instead of selected automaticaly if (2 == stArgLen) { szCode = argv[++i]; if (i >= argc) break; } else { szCode = argv[i] + 2; } if (0 == vm_string_strcmp(szCode, VM_STRING("def"))) { cc.uiPrefAudioRender = UMC::DEF_VIDEO_RENDER; } else if (0 == vm_string_strcmp(szCode, VM_STRING("dsound"))) { cc.uiPrefAudioRender = UMC::DSOUND_AUDIO_RENDER; } else if (0 == vm_string_strcmp(szCode, VM_STRING("winmm"))) { cc.uiPrefAudioRender = UMC::WINMM_AUDIO_RENDER; } else if (0 == vm_string_strcmp(szCode, VM_STRING("oss"))) { cc.uiPrefAudioRender = UMC::OSS_AUDIO_RENDER; } else if (0 == vm_string_strcmp(szCode, VM_STRING("fw"))) { cc.uiPrefAudioRender = UMC::FW_AUDIO_RENDER; } else if (0 == vm_string_strcmp(szCode, VM_STRING("nul"))) { cc.uiPrefAudioRender = UMC::NULL_AUDIO_RENDER; } break; } case 'f': case 'F': { vm_char* szCode = NULL; // Use predefined color format instead of selected automaticaly if (2 == stArgLen) { szCode = argv[++i]; if (i >= argc) break; } else { szCode = argv[i] + 2; } if (0 == vm_string_strcmp(szCode, VM_STRING("yv12"))) { cc.cformat = UMC::YV12; } else if (0 == vm_string_strcmp(szCode, VM_STRING("yuy2"))) { cc.cformat = UMC::YUY2; } else if (0 == vm_string_strcmp(szCode, VM_STRING("rgb565"))) { cc.cformat = UMC::RGB565; } break; } case 'v': case 'V': { vm_char* szCode = NULL; // Use predefined video render instead of selected automaticaly if (2 == stArgLen) { szCode = argv[++i]; if (i >= argc) break; } else { szCode = argv[i] + 2; } if (0 == vm_string_strcmp(szCode, VM_STRING("def"))) { cc.uiPrefVideoRender = UMC::DEF_VIDEO_RENDER; } else if (0 == vm_string_strcmp(szCode, VM_STRING("dx"))) { cc.uiPrefVideoRender = UMC::DX_VIDEO_RENDER; } else if (0 == vm_string_strcmp(szCode, VM_STRING("blt"))) { cc.uiPrefVideoRender = UMC::BLT_VIDEO_RENDER; } else if (0 == vm_string_strcmp(szCode, VM_STRING("gdi"))) { cc.uiPrefVideoRender = UMC::GDI_VIDEO_RENDER; } else if (0 == vm_string_strcmp(szCode, VM_STRING("gx"))) { cc.uiPrefVideoRender = UMC::GX_VIDEO_RENDER; } else if (0 == vm_string_strcmp(szCode, VM_STRING("sdl"))) { cc.uiPrefVideoRender = UMC::SDL_VIDEO_RENDER; } else if (0 == vm_string_strcmp(szCode, VM_STRING("fb"))) { cc.uiPrefVideoRender = UMC::FB_VIDEO_RENDER; } else if (0 == vm_string_strcmp(szCode, VM_STRING("nul"))) { cc.uiPrefVideoRender = UMC::NULL_VIDEO_RENDER; } else if (0 == vm_string_strcmp(szCode, VM_STRING("fw"))) { cc.uiPrefVideoRender = UMC::FW_VIDEO_RENDER; } else if (0 == vm_string_strcmp(szCode, VM_STRING("ovl2"))) { cc.uiPrefVideoRender = UMC::OVL2_VIDEO_RENDER; cc.cformat = UMC::YV12; } break; } default: vm_message(VM_STRING("Unknown option: %s\n"), argv[i]); PrintHelp(argv[0]); umcRes = UMC::UMC_FAILED_TO_INITIALIZE; break; } } else { if (0 == szFileName[0]) { i = FileNameFromParams(argc, argv, i, szFileName); } else { vm_message(VM_STRING("Too many file names in command line - %s and %s\n"), szFileName, argv[i]); PrintHelp(argv[0]); umcRes = UMC::UMC_FAILED_TO_INITIALIZE; } } i++; } if (UMC::UMC_OK == umcRes && 0 != szFileName[0]) { if (bPlayFromList) { umcRes = PlayListFromFile(AVSync, cc, szFileName, szPerfLogFileName, uiIterations, // in case of WinCE main() function // is called by WinMain(). So to signal // to main() it's time to stop WinMAin // uses first byte of first parameter // from argv[] array. To stop playing // WinMAin sets it to zero. argv[0]); } else { umcRes = PlaySingleFile(AVSync, cc, szFileName, szPerfLogFileName, uiIterations, argv[0]); } if (UMC::UMC_UNSUPPORTED == umcRes) vm_string_printf(VM_STRING("Unsupported media format\n")); } else { if (0 == szFileName[0]) { vm_message(VM_STRING("No file to play in command line\n")); PrintHelp(argv[0]); } } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -