Changeset 228 for trunk/Utilities/Miscellaneous/VideoResizerDsp01
- Timestamp:
- Dec 30, 2013, 12:32:53 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Utilities/Miscellaneous/VideoResizerDsp01/VideoResizerDsp01.cpp
r227 r228 3 3 // Created by Roman Ryltsov roman@alax.info 4 4 // 5 // NOTE: This is to demonstrate the bug 5 // NOTE: This is to demonstrate the bugs 6 // 6 7 // Video Resizer DSP's IMediaObject::SetOutputType returns E_POINTER when it is not supposed to 7 8 // http://connect.microsoft.com/VisualStudio/feedback/details/812418/video-resizer-dsps-imediaobject-setoutputtype-returns-e-pointer-when-it-is-not-supposed-to 9 // 10 // Digital Signal Processors do not honor flags arguments on DMO interface IMediaObject when setting input/output types 11 // https://connect.microsoft.com/VisualStudio/feedback/details/812482/digital-signal-processors-do-not-honor-flags-arguments-on-dmo-interface-imediaobject-when-setting-input-output-types 8 12 9 13 #include "stdafx.h" … … 16 20 #pragma comment(lib, "strmiids.lib") 17 21 #pragma comment(lib, "wmcodecdspuuid.lib") 22 #pragma comment(lib, "msdmo.lib") 23 24 //#define DSP CLSID_CResizerDMO 25 //#define OUTPUTSUBTYPE MEDIASUBTYPE_YV12 26 //#define OUTPUTWIDTH 1280 27 //#define OUTPUTHEIGHT 720 28 //#define OUTPUTBITCOUNT 12 29 30 #define DSP CLSID_CColorConvertDMO 31 #define OUTPUTSUBTYPE MEDIASUBTYPE_UYVY 32 #define OUTPUTWIDTH 1920 33 #define OUTPUTHEIGHT 1080 34 #define OUTPUTBITCOUNT 16 35 36 VOID PrintInputType(IMediaObject* pMediaObject, HRESULT nExpectedResult = S_OK, LPCTSTR pszComment = _T("")) 37 { 38 ATLASSERT(pMediaObject); 39 DMO_MEDIA_TYPE MediaType; 40 ZeroMemory(&MediaType, sizeof MediaType); 41 const HRESULT nGetInputCurrentTypeResult = pMediaObject->GetInputCurrentType(0, &MediaType); 42 if(nGetInputCurrentTypeResult != nExpectedResult && _tcslen(pszComment)) 43 _tprintf(_T("nGetInputCurrentTypeResult 0x%08x <<--- Incorrect, %s\n"), nGetInputCurrentTypeResult, pszComment); 44 else 45 _tprintf(_T("nGetInputCurrentTypeResult 0x%08x\n"), nGetInputCurrentTypeResult); 46 if(FAILED(nGetInputCurrentTypeResult)) 47 return; 48 ATLASSERT(MediaType.formattype == FORMAT_VideoInfo); 49 VIDEOINFOHEADER* pVideoInfoHeader = (VIDEOINFOHEADER*) MediaType.pbFormat; 50 ATLASSERT(MediaType.cbFormat >= sizeof *pVideoInfoHeader); 51 _tprintf(_T("Input: biWidth %d, biHeight %d\n"), pVideoInfoHeader->bmiHeader.biWidth, pVideoInfoHeader->bmiHeader.biHeight); 52 ATLVERIFY(SUCCEEDED(MoFreeMediaType(&MediaType))); 53 } 54 VOID PrintOutputType(IMediaObject* pMediaObject, HRESULT nExpectedResult = S_OK, LPCTSTR pszComment = _T("")) 55 { 56 ATLASSERT(pMediaObject); 57 DMO_MEDIA_TYPE MediaType; 58 ZeroMemory(&MediaType, sizeof MediaType); 59 const HRESULT nGetOutputCurrentTypeResult = pMediaObject->GetOutputCurrentType(0, &MediaType); 60 if(nGetOutputCurrentTypeResult != nExpectedResult && _tcslen(pszComment)) 61 _tprintf(_T("nGetOutputCurrentTypeResult 0x%08x <<--- Incorrect, %s\n"), nGetOutputCurrentTypeResult, pszComment); 62 else 63 _tprintf(_T("nGetOutputCurrentTypeResult 0x%08x\n"), nGetOutputCurrentTypeResult); 64 if(FAILED(nGetOutputCurrentTypeResult)) 65 return; 66 ATLASSERT(MediaType.formattype == FORMAT_VideoInfo); 67 VIDEOINFOHEADER* pVideoInfoHeader = (VIDEOINFOHEADER*) MediaType.pbFormat; 68 ATLASSERT(MediaType.cbFormat >= sizeof *pVideoInfoHeader); 69 _tprintf(_T("Output: biWidth %d, biHeight %d\n"), pVideoInfoHeader->bmiHeader.biWidth, pVideoInfoHeader->bmiHeader.biHeight); 70 ATLVERIFY(SUCCEEDED(MoFreeMediaType(&MediaType))); 71 } 18 72 19 73 int _tmain(int argc, _TCHAR* argv[]) … … 22 76 { 23 77 CComPtr<IMediaObject> pMediaObject; 24 ATLENSURE_SUCCEEDED(pMediaObject.CoCreateInstance(CLSID_CResizerDMO)); 78 ATLENSURE_SUCCEEDED(pMediaObject.CoCreateInstance(DSP)); 79 #pragma region Set 80 _tprintf(_T("\n*** Set ***\n\n")); 25 81 #pragma region Input 26 82 DMO_MEDIA_TYPE InputMediaType; … … 44 100 InputMediaType.cbFormat = sizeof InputVideoInfoHeader; 45 101 InputMediaType.pbFormat = (BYTE*) &InputVideoInfoHeader; 102 #pragma endregion 103 const HRESULT nTrySetInputTypeResult = pMediaObject->SetInputType(0, &InputMediaType, DMO_SET_TYPEF_TEST_ONLY); 104 _tprintf(_T("nTrySetInputTypeResult 0x%08x\n"), nTrySetInputTypeResult); 105 PrintInputType(pMediaObject, DMO_E_TYPE_NOT_SET, _T("we only tested, we did not set it")); 46 106 const HRESULT nSetInputTypeResult = pMediaObject->SetInputType(0, &InputMediaType, 0); 47 107 _tprintf(_T("nSetInputTypeResult 0x%08x\n"), nSetInputTypeResult); 48 #pragma endregion108 PrintInputType(pMediaObject); 49 109 #pragma region Output 50 110 DMO_MEDIA_TYPE OutputMediaType; 51 111 ZeroMemory(&OutputMediaType, sizeof OutputMediaType); 52 112 OutputMediaType.majortype = MEDIATYPE_Video; 53 OutputMediaType.subtype = InputMediaType.subtype;113 OutputMediaType.subtype = OUTPUTSUBTYPE; 54 114 OutputMediaType.bFixedSizeSamples = TRUE; 55 115 OutputMediaType.bTemporalCompression = FALSE; … … 58 118 BITMAPINFOHEADER& OutputBitmapInfoHeader = OutputVideoInfoHeader.bmiHeader; 59 119 OutputBitmapInfoHeader.biSize = sizeof OutputBitmapInfoHeader; 60 OutputBitmapInfoHeader.biWidth = 1280;61 OutputBitmapInfoHeader.biHeight = 720;120 OutputBitmapInfoHeader.biWidth = OUTPUTWIDTH; 121 OutputBitmapInfoHeader.biHeight = OUTPUTHEIGHT; 62 122 OutputBitmapInfoHeader.biPlanes = 1; 63 OutputBitmapInfoHeader.biBitCount = InputBitmapInfoHeader.biBitCount;123 OutputBitmapInfoHeader.biBitCount = OUTPUTBITCOUNT; 64 124 OutputBitmapInfoHeader.biCompression = OutputMediaType.subtype.Data1; 65 125 OutputBitmapInfoHeader.biSizeImage = OutputBitmapInfoHeader.biHeight * OutputBitmapInfoHeader.biWidth * OutputBitmapInfoHeader.biBitCount / 8; … … 68 128 OutputMediaType.cbFormat = sizeof OutputVideoInfoHeader; 69 129 OutputMediaType.pbFormat = (BYTE*) &OutputVideoInfoHeader; 130 #pragma endregion 131 const HRESULT nTrySetOutputTypeResult = pMediaObject->SetOutputType(0, &OutputMediaType, DMO_SET_TYPEF_TEST_ONLY); 132 _tprintf(_T("nTrySetOutputTypeResult 0x%08x\n"), nTrySetOutputTypeResult); 133 PrintOutputType(pMediaObject, DMO_E_TYPE_NOT_SET, _T("we only tested, we did not set it")); 70 134 const HRESULT nSetOutputTypeResult = pMediaObject->SetOutputType(0, &OutputMediaType, 0); 71 135 _tprintf(_T("nSetOutputTypeResult 0x%08x\n"), nSetOutputTypeResult); 136 PrintOutputType(pMediaObject); 72 137 #pragma endregion 138 ATLASSERT(nSetInputTypeResult == S_OK && nSetOutputTypeResult == S_OK); 139 #pragma region Clear 140 _tprintf(_T("\n*** Clear ***\n\n")); 73 141 const HRESULT nResetInputTypeResult = pMediaObject->SetInputType(0, NULL, DMO_SET_TYPEF_CLEAR); 142 _tprintf(_T("nResetInputTypeResult 0x%08x%s\n"), nResetInputTypeResult, FAILED(nResetInputTypeResult) ? _T(" <<--- Incorrect") : _T("")); 143 PrintInputType(pMediaObject); 74 144 const HRESULT nResetOutputTypeResult = pMediaObject->SetOutputType(0, NULL, DMO_SET_TYPEF_CLEAR); 75 _tprintf(_T("nResetInputTypeResult 0x%08x, nResetOutputTypeResult 0x%08x\n"), nResetInputTypeResult, nResetOutputTypeResult); 145 _tprintf(_T("nResetOutputTypeResult 0x%08x%s\n"), nResetOutputTypeResult, FAILED(nResetOutputTypeResult) ? _T(" <<--- Incorrect") : _T("")); 146 PrintOutputType(pMediaObject); 147 const HRESULT nAnotherResetInputTypeResult = pMediaObject->SetInputType(0, &InputMediaType, DMO_SET_TYPEF_CLEAR); 148 _tprintf(_T("nAnotherResetInputTypeResult 0x%08x%s\n"), nAnotherResetInputTypeResult, (nAnotherResetInputTypeResult == S_OK) ? _T(" <<--- Incorrect, clearing expects NULL argument") : _T("")); 149 PrintInputType(pMediaObject, DMO_E_TYPE_NOT_SET, _T("we were reported clearing success already")); 150 const HRESULT nAnotherResetOutputTypeResult = pMediaObject->SetOutputType(0, &OutputMediaType, DMO_SET_TYPEF_CLEAR); 151 _tprintf(_T("nAnotherResetOutputTypeResult 0x%08x%s\n"), nAnotherResetOutputTypeResult, (nAnotherResetOutputTypeResult == S_OK) ? _T(" <<--- Incorrect, clearing expects NULL argument") : _T("")); 152 PrintOutputType(pMediaObject, DMO_E_TYPE_NOT_SET, _T("we were reported clearing success already")); 153 #pragma endregion 76 154 } 77 155 CoUninitialize();
Note: See TracChangeset
for help on using the changeset viewer.