Changeset 174


Ignore:
Timestamp:
May 18, 2013, 11:19:04 PM (11 years ago)
Author:
roman
Message:

Added VMR-7 option

Location:
trunk/Utilities/StressEvr
Files:
3 added
2 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Utilities/StressEvr/MainDialog.h

    r166 r174  
    1515
    1616#pragma comment(lib, "dxgi.lib")
     17
     18////////////////////////////////////////////////////////////
     19// CVmr7Window
     20
     21class CVmr7Window :
     22        public CControlWindowT<CVmr7Window>
     23{
     24public:
     25
     26BEGIN_MSG_MAP_EX(CVmr7Window)
     27        //CHAIN_MSG_MAP(CControlWindowT<CVmr7Window>)
     28        MSG_WM_ERASEBKGND(OnEraseBkgnd)
     29        MSG_WM_PAINT(OnPaint)
     30        MSG_WM_DISPLAYCHANGE(OnDisplayChange)
     31        MSG_WM_SIZE(OnSize)
     32        MSG_WM_LBUTTONDBLCLK(OnLButtonDblClk)
     33END_MSG_MAP()
     34
     35public:
     36        CComPtr<IBaseFilter> m_pBaseFilter;
     37        CComPtr<IVMRWindowlessControl> m_pVmrWindowlessControl;
     38
     39public:
     40// CVmr7Window
     41        static CLSID GetRendererClassIdentifier() throw()
     42        {
     43                return CLSID_VideoMixingRenderer;
     44        }
     45        static CComPtr<IBaseFilter> CoCreateBaseFilterInstance()
     46        {
     47                CComPtr<IBaseFilter> pBaseFilter;
     48                __C(pBaseFilter.CoCreateInstance(GetRendererClassIdentifier()));
     49                return pBaseFilter;
     50        }
     51        VOID Initialize(IBaseFilter* pBaseFilter)
     52        {
     53                _A(pBaseFilter);
     54                _A(!m_pBaseFilter && !m_pVmrWindowlessControl);
     55                m_pBaseFilter = pBaseFilter;
     56                const CComQIPtr<IVMRFilterConfig> pVmrFilterConfig = pBaseFilter;
     57                __D(pVmrFilterConfig, E_NOINTERFACE);
     58                __C(pVmrFilterConfig->SetRenderingMode(VMRMode_Windowless));
     59                m_pVmrWindowlessControl = CComQIPtr<IVMRWindowlessControl>(m_pBaseFilter);
     60                __D(m_pVmrWindowlessControl, E_NOINTERFACE);
     61                __C(m_pVmrWindowlessControl->SetVideoClippingWindow(m_hWnd));
     62                CRect VideoPosition = GetVideoPosition();
     63                _Z4(atlTraceGeneral, 4, _T(".m_pVmrWindowlessControl 0x%p, VideoPosition at (%d, %d) size (%d, %d)\n"), m_pVmrWindowlessControl, VideoPosition.left, VideoPosition.top, VideoPosition.Width(), VideoPosition.Height());
     64                __C(m_pVmrWindowlessControl->SetVideoPosition(NULL, VideoPosition));
     65        }
     66        VOID Terminate() throw()
     67        {
     68                m_pBaseFilter = NULL;
     69                m_pVmrWindowlessControl = NULL;
     70        }
     71        CRect GetVideoPosition() const throw()
     72        {
     73                CRect Position;
     74                _W(GetClientRect(Position));
     75                return Position;
     76        }
     77
     78// Window Message Handlers
     79        LRESULT OnEraseBkgnd(CDCHandle Dc)
     80        {
     81                Dc;
     82                if(m_pVmrWindowlessControl)
     83                {
     84                        return TRUE;
     85                } else
     86                        SetMsgHandled(FALSE);
     87                return 0;
     88        }
     89        LRESULT OnPaint(CDCHandle)
     90        {
     91                if(m_pVmrWindowlessControl)
     92                {
     93                        CPaintDC Dc(m_hWnd);
     94                        const HRESULT nRepaintVideoResult = m_pVmrWindowlessControl->RepaintVideo(m_hWnd, Dc);
     95                        _Z45_HRESULT(nRepaintVideoResult);
     96                } else
     97                        SetMsgHandled(FALSE);
     98                return 0;
     99        }
     100        LRESULT OnDisplayChange(UINT nDepth, CSize Extent)
     101        {
     102                if(m_pVmrWindowlessControl)
     103                {
     104                        const HRESULT nDisplayModeChangedResult = m_pVmrWindowlessControl->DisplayModeChanged();
     105                        _Z45_HRESULT(nDisplayModeChangedResult);
     106                }
     107                return 0;
     108        }
     109        LRESULT OnSize(UINT nType, CSize)
     110        {
     111                if(nType != SIZE_MINIMIZED)
     112                        if(m_pVmrWindowlessControl)
     113                        {
     114                                CRect VideoPosition = GetVideoPosition();
     115                                const HRESULT nSetVideoPositionResult = m_pVmrWindowlessControl->SetVideoPosition(NULL, &VideoPosition);
     116                                _Z45_HRESULT(nSetVideoPositionResult);
     117                        }
     118                return 0;
     119        }
     120        LRESULT OnLButtonDblClk(UINT, CPoint)
     121        {
     122                COlePropertyFrameDialog Dialog(m_pBaseFilter, _T("VMR-7"));
     123                Dialog.SetObjectPages();
     124                Dialog.DoModal(m_hWnd);
     125                return 0;
     126        }
     127};
    17128
    18129////////////////////////////////////////////////////////////
     
    140251        LRESULT OnLButtonDblClk(UINT, CPoint Position)
    141252        {
    142                 COlePropertyFrameDialog Dialog;
    143                 Dialog.SetObject(m_pBaseFilter);
     253                COlePropertyFrameDialog Dialog(m_pBaseFilter, _T("EVR"));
    144254                Dialog.SetObjectPages();
    145255                Dialog.DoModal(m_hWnd);
     
    149259
    150260////////////////////////////////////////////////////////////
    151 // CVideoDialog
    152 
    153 class CVideoDialog :
    154         public CDialogImpl<CVideoDialog>,
    155         public CDialogResize<CVideoDialog>
     261// CBaseVideoDialog
     262
     263class CBaseVideoDialog
    156264{
     265public:
     266// CBaseVideoDialog
     267        virtual HWND Create(HWND hParentWindow) = 0;
     268        virtual BOOL DestroyWindow() = 0;
     269        virtual BOOL IsWindow() = 0;
     270        virtual BOOL MoveWindow(const CRect& Position) = 0;
     271        virtual INT ShowWindow(INT nShowCommand) = 0;
     272};
     273
     274////////////////////////////////////////////////////////////
     275// CVideoDialogT
     276
     277template <typename T, typename CVrWindow, LPCTSTR* t_ppszType>
     278class CVideoDialogT :
     279        public CDialogImpl<T>,
     280        public CDialogResize<T>,
     281        public CBaseVideoDialog
     282{
     283        typedef CVideoDialogT<T, CVrWindow, t_ppszType> CVideoDialog;
     284
    157285public:
    158286        enum { IDD = IDD_VIDEO };
     
    160288BEGIN_MSG_MAP_EX(CVideoDialog)
    161289        //CHAIN_MSG_MAP(CDialogImpl<CVideoDialog>)
    162         CHAIN_MSG_MAP(CDialogResize<CVideoDialog>)
     290        CHAIN_MSG_MAP(CDialogResize<T>)
    163291        MSG_WM_INITDIALOG(OnInitDialog)
    164292        MSG_WM_DESTROY(OnDestroy)
     
    379507        CStatic m_AreaStatic;
    380508        CGenericFilterGraph m_FilterGraph;
    381         CRoArrayT<CEvrWindow> m_EvrWindowArray;
     509        CRoArrayT<CVrWindow> m_VrWindowArray;
    382510        CButton m_RunButton;
    383511        CButton m_PauseButton;
     
    441569public:
    442570// CVideoDialog
    443         CVideoDialog(const CMediaType& pMediaType, SIZE_T nLayout) :
     571        CVideoDialogT(const CMediaType& pMediaType, SIZE_T nLayout) :
    444572                m_pMediaType(pMediaType),
    445573                m_nLayout(nLayout)
     
    447575                _Z4(atlTraceRefcount, 4, _T("this 0x%p\n"), this);
    448576        }
    449         ~CVideoDialog() throw()
     577        ~CVideoDialogT() throw()
    450578        {
    451579                _Z4(atlTraceRefcount, 4, _T("this 0x%p\n"), this);
     580        }
     581
     582// CDialogImpl
     583        VOID OnFinalMessage(HWND)
     584        {
     585                T* pT = static_cast<T*>(this);
     586                delete pT;
     587        }
     588
     589// CBaseVideoDialog
     590        HWND Create(HWND hParentWindow)
     591        {
     592                return CDialogImpl<T>::Create(hParentWindow);
     593        }
     594        BOOL DestroyWindow()
     595        {
     596                return CDialogImpl<T>::DestroyWindow();
     597        }
     598        BOOL IsWindow()
     599        {
     600                return CDialogImpl<T>::IsWindow();
     601        }
     602        BOOL MoveWindow(const CRect& Position)
     603        {
     604                return CDialogImpl<T>::MoveWindow(Position);
     605        }
     606        INT ShowWindow(INT nShowCommand)
     607        {
     608                return CDialogImpl<T>::ShowWindow(nShowCommand);
    452609        }
    453610
     
    460617                _W(ScreenToClient(Position));
    461618                CDeferWindowPos DeferWindowPos;
    462                 _W(DeferWindowPos.Begin((INT) m_EvrWindowArray.GetCount()));
    463                 for(SIZE_T nIndex = 0; nIndex < m_EvrWindowArray.GetCount(); nIndex++)
    464                         _W(DeferWindowPos.SetWindowPos(m_EvrWindowArray[nIndex], NULL, GetVideoPosition(Position, nIndex), SWP_NOZORDER | SWP_NOACTIVATE));
     619                _W(DeferWindowPos.Begin((INT) m_VrWindowArray.GetCount()));
     620                for(SIZE_T nIndex = 0; nIndex < m_VrWindowArray.GetCount(); nIndex++)
     621                        _W(DeferWindowPos.SetWindowPos(m_VrWindowArray[nIndex], NULL, GetVideoPosition(Position, nIndex), SWP_NOZORDER | SWP_NOACTIVATE));
    465622                _W(DeferWindowPos.End());
    466623        }
     
    478635                m_FilterGraph.CoCreateInstance();
    479636                const SIZE_T nCount = (m_nLayout + 1) * (m_nLayout + 1); // 1, 4, 9, 16, ...
    480                 _A(m_EvrWindowArray.IsEmpty());
    481                 _W(m_EvrWindowArray.SetCount(0, (INT) nCount));
     637                _A(m_VrWindowArray.IsEmpty());
     638                _W(m_VrWindowArray.SetCount(0, (INT) nCount));
    482639                for(SIZE_T nIndex = 0; nIndex < nCount; nIndex++)
    483640                {
    484                         CEvrWindow& EvrWindow = m_EvrWindowArray[m_EvrWindowArray.Add()];
    485                         CComPtr<IBaseFilter> pBaseFilter = CEvrWindow::CoCreateBaseFilterInstance();
     641                        CVrWindow& VrWindow = m_VrWindowArray[m_VrWindowArray.Add()];
     642                        CComPtr<IBaseFilter> pBaseFilter = CVrWindow::CoCreateBaseFilterInstance();
    486643                        __C(m_FilterGraph->AddFilter(pBaseFilter, CT2CW(AtlFormatString(_T("Renderer %02d"), nIndex + 1))));
    487                         EvrWindow.Create(m_hWnd);
    488                         EvrWindow.ShowWindow(SW_SHOWNORMAL);
    489                         EvrWindow.Initialize(pBaseFilter);
     644                        VrWindow.Create(m_hWnd);
     645                        VrWindow.ShowWindow(SW_SHOWNORMAL);
     646                        VrWindow.Initialize(pBaseFilter);
    490647                        CObjectPtr<CSourceFilter> pSourceFilter;
    491648                        pSourceFilter.Construct()->Initialize(m_pMediaType);
    492649                        __C(m_FilterGraph->AddFilter(pSourceFilter, CT2CW(AtlFormatString(_T("Source %02d"), nIndex + 1))));
    493                         m_FilterGraph->Connect(pSourceFilter->GetOutputPin(), _FilterGraphHelper::GetFilterPin(EvrWindow.m_pBaseFilter));
     650                        m_FilterGraph->Connect(pSourceFilter->GetOutputPin(), _FilterGraphHelper::GetFilterPin(VrWindow.m_pBaseFilter));
    494651                }
    495652                __C(m_FilterGraph.m_pMediaEventEx->SetNotifyWindow((OAHWND) m_hWnd, WM_FILTERGRAPHEVENT, (LONG_PTR) this));
     
    501658                GetWindowText(sCaption);
    502659                const CSize Extent = m_pMediaType.GetCompatibleVideoInfoHeader().GetExtent();
    503                 SetWindowText(AtlFormatString(sCaption, nCount, Extent.cx, Extent.cy));
     660                SetWindowText(AtlFormatString(sCaption, nCount, *t_ppszType, Extent.cx, Extent.cy));
    504661                return 0;
    505662        }
     
    508665                if(m_FilterGraph.m_pMediaControl)
    509666                        _V(m_FilterGraph.m_pMediaControl->Stop());
    510                 for(SIZE_T nIndex = 0; nIndex < m_EvrWindowArray.GetCount(); nIndex++)
    511                         m_EvrWindowArray[nIndex].Terminate();
     667                for(SIZE_T nIndex = 0; nIndex < m_VrWindowArray.GetCount(); nIndex++)
     668                        m_VrWindowArray[nIndex].Terminate();
    512669                m_FilterGraph.Release();
     670                CWindow OwnerWindow = GetWindow(GW_OWNER);
     671                if(OwnerWindow.IsWindow())
     672                        OwnerWindow.SendMessage(WM_COMMAND, 'CL', (LPARAM) (CBaseVideoDialog*) this);
    513673                return 0;
    514674        }
     
    586746
    587747////////////////////////////////////////////////////////////
     748// CVmr7VideoDialog, CEvrVideoDialog
     749
     750LPCTSTR g_pszVmr7 = _T("VMR-7");
     751
     752class CVmr7VideoDialog :
     753        public CVideoDialogT<CVmr7VideoDialog, CVmr7Window, &g_pszVmr7>
     754{
     755public:
     756// CVmr7VideoDialog
     757        CVmr7VideoDialog(const CMediaType& pMediaType, SIZE_T nLayout) :
     758                CVideoDialogT<CVmr7VideoDialog, CVmr7Window, &g_pszVmr7>(pMediaType, nLayout)
     759        {
     760        }
     761};
     762
     763LPCTSTR g_pszEvr = _T("EVR");
     764
     765class CEvrVideoDialog :
     766        public CVideoDialogT<CEvrVideoDialog, CEvrWindow, &g_pszEvr>
     767{
     768public:
     769// CEvrVideoDialog
     770        CEvrVideoDialog(const CMediaType& pMediaType, SIZE_T nLayout) :
     771                CVideoDialogT<CEvrVideoDialog, CEvrWindow, &g_pszEvr>(pMediaType, nLayout)
     772        {
     773        }
     774};
     775
     776////////////////////////////////////////////////////////////
    588777// CMainDialog
    589778
     
    602791        COMMAND_ID_HANDLER_EX(IDCANCEL, OnCommand)
    603792        COMMAND_ID_HANDLER_EX(IDC_CREATE, OnCreateButtonClicked)
     793        COMMAND_ID_HANDLER_EX('CL', OnCloseVideoDialog)
    604794        REFLECT_NOTIFICATIONS()
    605795END_MSG_MAP()
     
    620810        CComPtr<IDXGIFactory> m_pDxgiFactory;
    621811        CRect m_DefaultPosition;
    622         CRoListT<CAutoPtr<CVideoDialog>> m_VideoDialogList;
     812        CRoListT<CBaseVideoDialog*> m_VideoDialogList;
    623813
    624814public:
     
    640830                        GetWindowText(sCaption);
    641831                        #if defined(_WIN64)
    642                         sCaption.Append(_T(" (64-bit)"));
     832                                sCaption.Append(_T(" (64-bit)"));
    643833                        #else
    644                         if(SafeIsWow64Process())
    645                                 sCaption.Append(_T(" (32-bit)"));
     834                                if(SafeIsWow64Process())
     835                                        sCaption.Append(_T(" (32-bit)"));
    646836                        #endif // defined(_WIN64)
    647837                        SetWindowText(sCaption);
    648838                }
    649839                _W(CenterWindow());
     840                CButton(GetDlgItem(IDC_TYPE_EVR)).SetCheck(TRUE);
    650841                CButton(GetDlgItem(IDC_RESOLUTION_19201080)).SetCheck(TRUE);
    651842                CButton(GetDlgItem(IDC_PIXELFORMAT_NV12)).SetCheck(TRUE);
     
    677868                for(POSITION Position = m_VideoDialogList.GetHeadPosition(); Position; m_VideoDialogList.GetNext(Position))
    678869                {
    679                         CAutoPtr<CVideoDialog>& pVideoDialog = m_VideoDialogList.GetAt(Position);
     870                        CBaseVideoDialog* pVideoDialog = m_VideoDialogList.GetAt(Position);
    680871                        _A(pVideoDialog);
    681872                        if(pVideoDialog->IsWindow())
     
    763954                CWaitCursor WaitCursor;
    764955                #pragma region Query Controls
     956                SIZE_T nType;
     957                for(INT nIdentifier = IDC_TYPE_VMR7; nIdentifier <= IDC_TYPE_EVR; nIdentifier++)
     958                        if(IsDlgButtonChecked(nIdentifier))
     959                        {
     960                                nType = nIdentifier - IDC_TYPE_VMR7;
     961                                break;
     962                        }
    765963                SIZE_T nResolution;
    766964                for(INT nIdentifier = IDC_RESOLUTION_720576; nIdentifier <= IDC_RESOLUTION_19201080; nIdentifier++)
     
    790988                CMediaType pMediaType;
    791989                pMediaType.AllocateVideoInfo(g_pExtents[nResolution], g_pnBitCounts[nPixelFormat], g_pnCompressions[nPixelFormat]);
    792                 CVideoDialog* pVideoDialog = new CVideoDialog(pMediaType, nLayout);
     990                CBaseVideoDialog* pVideoDialog;
     991                switch(nType)
     992                {
     993                case 0: // IDC_TYPE_VMR7
     994                        pVideoDialog = new CVmr7VideoDialog(pMediaType, nLayout);
     995                        break;
     996                case 1: // IDC_TYPE_EVR
     997                        pVideoDialog = new CEvrVideoDialog(pMediaType, nLayout);
     998                        break;
     999                default:
     1000                        __C(E_NOTIMPL);
     1001                }
    7931002                _ATLTRY
    7941003                {
     
    8081017                                _W(pVideoDialog->MoveWindow(Position));
    8091018                                pVideoDialog->ShowWindow(SW_SHOWNORMAL);
    810                                 m_VideoDialogList.GetAt(m_VideoDialogList.AddTail()).Attach(pVideoDialog);
     1019                                m_VideoDialogList.AddTail(pVideoDialog);
    8111020                        }
    8121021                        _ATLCATCHALL()
     
    8231032                return 0;
    8241033        }
     1034        LRESULT OnCloseVideoDialog(UINT, INT, HWND hWindow)
     1035        {
     1036                CBaseVideoDialog* pBaseVideoDialog = (CBaseVideoDialog*) hWindow;
     1037                POSITION Position;
     1038                if(m_VideoDialogList.FindFirst(pBaseVideoDialog, &Position))
     1039                        m_VideoDialogList.RemoveAt(Position);
     1040                return 0;
     1041        }
    8251042};
  • trunk/Utilities/StressEvr/StressEvr.sln

    r56 r174  
    11
    22Microsoft Visual Studio Solution File, Format Version 11.00
    3 # Visual Studio 2010
     3# Visual Studio 2012
    44Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StressEvr", "StressEvr.vcxproj", "{D5F58BC2-453A-4C4E-888E-9C7C511D8FD4}"
    55EndProject
  • trunk/Utilities/StressEvr/StressEvr_i.c

    r166 r174  
    77
    88 /* File created by MIDL compiler version 7.00.0555 */
    9 /* at Mon Jan 21 21:25:14 2013
     9/* at Sun May 19 09:17:42 2013
    1010 */
    1111/* Compiler settings for StressEvr.idl:
  • trunk/Utilities/StressEvr/StressEvr_i.h

    r166 r174  
    55
    66 /* File created by MIDL compiler version 7.00.0555 */
    7 /* at Mon Jan 21 21:25:14 2013
     7/* at Sun May 19 09:17:42 2013
    88 */
    99/* Compiler settings for StressEvr.idl:
Note: See TracChangeset for help on using the changeset viewer.