Changeset 228


Ignore:
Timestamp:
Dec 30, 2013, 12:32:53 AM (8 years ago)
Author:
roman
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Utilities/Miscellaneous/VideoResizerDsp01/VideoResizerDsp01.cpp

    r227 r228  
    33// Created by Roman Ryltsov roman@alax.info
    44//
    5 // NOTE: This is to demonstrate the bug
     5// NOTE: This is to demonstrate the bugs
     6//
    67//       Video Resizer DSP's IMediaObject::SetOutputType returns E_POINTER when it is not supposed to
    78//       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
    812
    913#include "stdafx.h"
     
    1620#pragma comment(lib, "strmiids.lib")
    1721#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
     36VOID 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}
     54VOID 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}
    1872
    1973int _tmain(int argc, _TCHAR* argv[])
     
    2276        {
    2377                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"));
    2581                #pragma region Input
    2682                DMO_MEDIA_TYPE InputMediaType;
     
    44100                InputMediaType.cbFormat = sizeof InputVideoInfoHeader;
    45101                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"));
    46106                const HRESULT nSetInputTypeResult = pMediaObject->SetInputType(0, &InputMediaType, 0);
    47107                _tprintf(_T("nSetInputTypeResult 0x%08x\n"), nSetInputTypeResult);
    48                 #pragma endregion
     108                PrintInputType(pMediaObject);
    49109                #pragma region Output
    50110                DMO_MEDIA_TYPE OutputMediaType;
    51111                ZeroMemory(&OutputMediaType, sizeof OutputMediaType);
    52112                OutputMediaType.majortype = MEDIATYPE_Video;
    53                 OutputMediaType.subtype = InputMediaType.subtype;
     113                OutputMediaType.subtype = OUTPUTSUBTYPE;
    54114                OutputMediaType.bFixedSizeSamples = TRUE;
    55115                OutputMediaType.bTemporalCompression = FALSE;
     
    58118                BITMAPINFOHEADER& OutputBitmapInfoHeader = OutputVideoInfoHeader.bmiHeader;
    59119        OutputBitmapInfoHeader.biSize = sizeof OutputBitmapInfoHeader;
    60         OutputBitmapInfoHeader.biWidth = 1280;
    61         OutputBitmapInfoHeader.biHeight = 720;
     120        OutputBitmapInfoHeader.biWidth = OUTPUTWIDTH;
     121        OutputBitmapInfoHeader.biHeight = OUTPUTHEIGHT;
    62122        OutputBitmapInfoHeader.biPlanes = 1;
    63         OutputBitmapInfoHeader.biBitCount = InputBitmapInfoHeader.biBitCount;
     123                OutputBitmapInfoHeader.biBitCount = OUTPUTBITCOUNT;
    64124                OutputBitmapInfoHeader.biCompression = OutputMediaType.subtype.Data1;
    65125        OutputBitmapInfoHeader.biSizeImage = OutputBitmapInfoHeader.biHeight * OutputBitmapInfoHeader.biWidth * OutputBitmapInfoHeader.biBitCount / 8;
     
    68128                OutputMediaType.cbFormat = sizeof OutputVideoInfoHeader;
    69129                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"));
    70134                const HRESULT nSetOutputTypeResult = pMediaObject->SetOutputType(0, &OutputMediaType, 0);
    71135                _tprintf(_T("nSetOutputTypeResult 0x%08x\n"), nSetOutputTypeResult);
     136                PrintOutputType(pMediaObject);
    72137                #pragma endregion
     138                ATLASSERT(nSetInputTypeResult == S_OK && nSetOutputTypeResult == S_OK);
     139                #pragma region Clear
     140                _tprintf(_T("\n*** Clear ***\n\n"));
    73141                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);
    74144                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
    76154        }
    77155        CoUninitialize();
Note: See TracChangeset for help on using the changeset viewer.