//////////////////////////////////////////////////////////// // Copyright (C) Roman Ryltsov, 2008-2011 // Created by Roman Ryltsov roman@alax.info // // $Id$ #include "stdafx.h" #include #pragma comment(lib, "vfw32.lib") CString StringFromFourcc(DWORD nCode) { CString sText = AtlFormatString(_T("0x%08x"), nCode); union { DWORD nCode; CHAR pszText[5]; } Value; Value.nCode = nCode; Value.pszText[4] = 0; if(Value.pszText[0] >= 0x20 && Value.pszText[1] >= 0x20 && Value.pszText[2] >= 0x20 && Value.pszText[3] >= 0x20) sText += AtlFormatString(_T(" (%hs)"), Value.pszText); return sText; } CString StringFromFlags(DWORD nValue) { static const struct { LPCTSTR pszName; DWORD nValue; } g_pMap[] = { { _T("VIDCF_QUALITY"), 0x0001 }, { _T("VIDCF_CRUNCH"), 0x0002 }, { _T("VIDCF_TEMPORAL"), 0x0004 }, { _T("VIDCF_COMPRESSFRAMES"), 0x0008 }, { _T("VIDCF_DRAW"), 0x0010 }, { _T("VIDCF_FASTTEMPORALC"), 0x0020 }, { _T("VIDCF_FASTTEMPORALD"), 0x0080 }, { _T("VIDCF_QUALITYTIME"), 0x0040 }, }; CString sText; DWORD nNamedValue = 0; for(SIZE_T nIndex = 0; nIndex < DIM(g_pMap); nIndex++) if(nValue & g_pMap[nIndex].nValue) { if(!sText.IsEmpty()) sText.Append(_T(" |")); sText.Append(g_pMap[nIndex].pszName); nNamedValue |= g_pMap[nIndex].nValue; } if(nValue & ~nNamedValue) { if(!sText.IsEmpty()) sText.Append(_T(" | ")); sText.AppendFormat(_T("0x%x"), nValue & ~nNamedValue); } if(sText.IsEmpty()) sText.Append(_T("0")); return sText; } VOID Print(const ICINFO& Information, LPCTSTR pszName, LPCTSTR pszPrefix = _T("")) { _tprintf( _T("%s") _T("%s: szName %ls\n") _T("%s") _T(" fccType %s, fccHandler %s\n") _T("%s") _T(" dwFlags %s\n") _T("%s") _T(" dwVersion 0x%x, dwVersionICM 0x%x\n") _T("%s") _T(" szDescription \"%ls\"\n") _T("%s") _T(" szDriver \"%ls\"\n") , pszPrefix, pszName, (LPCWSTR) Information.szName, pszPrefix, StringFromFourcc(Information.fccType), StringFromFourcc(Information.fccHandler), pszPrefix, StringFromFlags(Information.dwFlags), pszPrefix, Information.dwVersion, Information.dwVersionICM, pszPrefix, (LPCWSTR) Information.szDescription, pszPrefix, (LPCWSTR) Information.szDriver, 0); } int _tmain(int argc, _TCHAR* argv[]) { _ATLTRY { #pragma region Command-Line Arguments BOOL bOpen = FALSE; BOOL bCompressorChooose = FALSE; for(int nIndex = 1; nIndex < argc; nIndex++) { CString sArgument = argv[nIndex]; _A(!sArgument.IsEmpty()); if(_tcschr(_T("-/"), sArgument[0])) { sArgument.Delete(0); if(sArgument.CompareNoCase(_T("o")) == 0) { bOpen = TRUE; } else if(sArgument.CompareNoCase(_T("c")) == 0) { bCompressorChooose = TRUE; } else __C(E_INVALIDARG); } else __C(E_INVALIDARG); } #pragma endregion for(UINT nIndex = 0; ; nIndex++) { #pragma region ICInfo ICINFO Information; ZeroMemory(&Information, sizeof Information); Information.dwSize = sizeof Information; if(!ICInfo(0, nIndex, &Information)) break; Print(Information, _T("ICInfo")); #pragma endregion #pragma region ICOpen if(!bOpen) continue; static const struct { UINT nMode; LPCTSTR pszName; } g_pModes[] = { { ICMODE_COMPRESS, _T("ICMODE_COMPRESS") }, { ICMODE_DECOMPRESS, _T("ICMODE_DECOMPRESS") }, { ICMODE_FASTDECOMPRESS, _T("ICMODE_FASTDECOMPRESS") }, { ICMODE_QUERY, _T("ICMODE_QUERY") }, { ICMODE_FASTCOMPRESS, _T("ICMODE_FASTCOMPRESS") }, }; for(SIZE_T nIndex = 0; nIndex < DIM(g_pModes); nIndex++) { HIC hImageCompressor = ICOpen(Information.fccType, Information.fccHandler, g_pModes[nIndex].nMode); if(!hImageCompressor) continue; _tprintf(_T(" ") _T("ICOpen: wMode %s (%d)\n"), g_pModes[nIndex].pszName, g_pModes[nIndex].nMode); #pragma region ICGetInfo ICINFO Information; ZeroMemory(&Information, sizeof Information); Information.dwSize = sizeof Information; if(ICGetInfo(hImageCompressor, &Information, sizeof Information)) Print(Information, _T("ICGetInfo"), _T(" ")); #pragma endregion _W(ICClose(hImageCompressor) == ICERR_OK); } #pragma endregion } if(bCompressorChooose) { COMPVARS CompressionVaraibles; ZeroMemory(&CompressionVaraibles, sizeof CompressionVaraibles); CompressionVaraibles.cbSize = sizeof CompressionVaraibles; ICCompressorChoose(GetActiveWindow(), ICMF_CHOOSE_ALLCOMPRESSORS, NULL, NULL, &CompressionVaraibles, NULL); } } _ATLCATCH(Exception) { _tprintf(_T("Fatal Error 0x%08x\n"), (HRESULT) Exception); } _ATLCATCHALL() { _tprintf(_T("Fatal Error\n")); } return 0; }