source: trunk/Utilities/Miscellaneous/ColorConvertDmo01/ColorConvertDmo01.cpp @ 215

Last change on this file since 215 was 215, checked in by roman, 9 years ago
File size: 2.5 KB
Line 
1// ColorConvertDmo01.cpp : Defines the entry point for the console application.
2//
3
4#include "stdafx.h"
5#include <dshow.h>
6#include <dmo.h>
7#include <wmcodecdsp.h>
8
9#pragma comment(lib, "strmiids.lib")
10#pragma comment(lib, "wmcodecdspuuid.lib")
11
12int _tmain(int argc, _TCHAR* argv[])
13{
14    ATLVERIFY(SUCCEEDED(CoInitialize(NULL)));
15    CComPtr<IMediaObject> pMediaObject;
16    ATLVERIFY(SUCCEEDED(pMediaObject.CoCreateInstance(CLSID_CColorConvertDMO)));
17    VIDEOINFOHEADER InputVideoInfoHeader;
18    ZeroMemory(&InputVideoInfoHeader, sizeof InputVideoInfoHeader);
19    InputVideoInfoHeader.bmiHeader.biSize = sizeof InputVideoInfoHeader.bmiHeader;
20    InputVideoInfoHeader.bmiHeader.biWidth = 1920;
21    InputVideoInfoHeader.bmiHeader.biHeight = 1080;
22    InputVideoInfoHeader.bmiHeader.biPlanes = 1;
23    InputVideoInfoHeader.bmiHeader.biBitCount = 24;
24    InputVideoInfoHeader.bmiHeader.biCompression = BI_RGB;
25    InputVideoInfoHeader.bmiHeader.biSizeImage = 1080 * (1920 * 3);
26    DMO_MEDIA_TYPE InputMediaType;
27    ZeroMemory(&InputMediaType, sizeof InputMediaType);
28    InputMediaType.majortype = MEDIATYPE_Video;
29    InputMediaType.subtype = MEDIASUBTYPE_RGB24;
30    InputMediaType.bFixedSizeSamples = TRUE;
31    InputMediaType.bTemporalCompression = FALSE;
32    InputMediaType.lSampleSize = InputVideoInfoHeader.bmiHeader.biSizeImage;
33    InputMediaType.formattype = FORMAT_VideoInfo;
34    InputMediaType.cbFormat = sizeof InputVideoInfoHeader;
35    InputMediaType.pbFormat = (BYTE*) &InputVideoInfoHeader;
36    const HRESULT nSetInputTypeResult = pMediaObject->SetInputType(0, &InputMediaType, 0);
37    _tprintf(_T("nSetInputTypeResult 0x%08x\n"), nSetInputTypeResult);
38    VIDEOINFOHEADER OutputVideoInfoHeader = InputVideoInfoHeader;
39    OutputVideoInfoHeader.bmiHeader.biBitCount = 12;
40    OutputVideoInfoHeader.bmiHeader.biCompression = MAKEFOURCC('Y', 'V', '1', '2');
41    OutputVideoInfoHeader.bmiHeader.biSizeImage = 1080 * 1920 * 12 / 8;
42    DMO_MEDIA_TYPE OutputMediaType = InputMediaType;
43    OutputMediaType.subtype = MEDIASUBTYPE_YV12;
44    OutputMediaType.lSampleSize = OutputVideoInfoHeader.bmiHeader.biSizeImage;
45    OutputMediaType.cbFormat = sizeof OutputVideoInfoHeader;
46    OutputMediaType.pbFormat = (BYTE*) &OutputVideoInfoHeader;
47    const HRESULT nSetOutputTypeResult = pMediaObject->SetOutputType(0, &OutputMediaType, 0);
48    _tprintf(_T("nSetOutputTypeResult 0x%08x\n"), nSetOutputTypeResult);
49    // TODO: ProcessInput, ProcessOutput
50    pMediaObject.Release();
51    CoUninitialize();
52    return 0;
53}
54
Note: See TracBrowser for help on using the repository browser.