Alax.Info ATL/WTL Utilities is an open source project powered by Assembla

Assembla offers free public and private SVN/Git repositories and project hosting with bug/issue tracking and collaboration tools.

/trunkEnumerateVcmCodecs
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
////////////////////////////////////////////////////////////
// Copyright (C) Roman Ryltsov, 2008-2011
// Created by Roman Ryltsov roman@alax.info
//
// $Id$

#include "stdafx.h"
#include <vfw.h>

#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;
}
Ajax-loader Loading, please wait...