Changeset 75


Ignore:
Timestamp:
Jul 15, 2012, 4:40:00 AM (11 years ago)
Author:
roman
Message:

VMR-7, EVR, Weave and Colorize options

Location:
trunk/Utilities/RenderInterlacedVideo
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Utilities/RenderInterlacedVideo/MainPropertySheet.h

    r74 r75  
    1515#include <dxva.h>
    1616#include "rodshow.h"
     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                CComQIPtr<IVMRFilterConfig> pVmrFilterConfig = pBaseFilter;
     57                __D(pVmrFilterConfig, E_NOINTERFACE);
     58                __C(pVmrFilterConfig->SetRenderingMode(VMRMode_Windowless));
     59                // NOTE: Cause the VMR to load the mixer and compositor
     60                //       See http://msdn.microsoft.com/en-us/library/windows/desktop/dd390448%28v=vs.85%29.aspx
     61                __C(pVmrFilterConfig->SetNumberOfStreams(1));
     62                m_pVmrWindowlessControl = CComQIPtr<IVMRWindowlessControl>(m_pBaseFilter);
     63                __D(m_pVmrWindowlessControl, E_NOINTERFACE);
     64                __C(m_pVmrWindowlessControl->SetVideoClippingWindow(m_hWnd));
     65                CRect VideoPosition = GetVideoPosition();
     66                _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());
     67                __C(m_pVmrWindowlessControl->SetVideoPosition(NULL, VideoPosition));
     68        }
     69        VOID Terminate() throw()
     70        {
     71                m_pBaseFilter = NULL;
     72                m_pVmrWindowlessControl = NULL;
     73        }
     74        CRect GetVideoPosition() const throw()
     75        {
     76                CRect Position;
     77                _W(GetClientRect(Position));
     78                return Position;
     79        }
     80
     81// Window Message Handlers
     82        LRESULT OnEraseBkgnd(CDCHandle Dc)
     83        {
     84                Dc;
     85                if(m_pVmrWindowlessControl)
     86                {
     87                        return TRUE;
     88                } else
     89                        SetMsgHandled(FALSE);
     90                return 0;
     91        }
     92        LRESULT OnPaint(CDCHandle)
     93        {
     94                if(m_pVmrWindowlessControl)
     95                {
     96                        CPaintDC Dc(m_hWnd);
     97                        const HRESULT nRepaintVideoResult = m_pVmrWindowlessControl->RepaintVideo(m_hWnd, Dc);
     98                        _Z4(atlTraceUI, SUCCEEDED(nRepaintVideoResult) ? 6 : 4, _T("nRepaintVideoResult 0x%08x\n"), nRepaintVideoResult);
     99                } else
     100                        SetMsgHandled(FALSE);
     101                return 0;
     102        }
     103        LRESULT OnDisplayChange(UINT nDepth, CSize Extent)
     104        {
     105                if(m_pVmrWindowlessControl)
     106                {
     107                        const HRESULT nDisplayModeChangedResult = m_pVmrWindowlessControl->DisplayModeChanged();
     108                        _Z4(atlTraceUI, 4, _T("nDisplayModeChangedResult 0x%08x\n"), nDisplayModeChangedResult);
     109                }
     110                return 0;
     111        }
     112        LRESULT OnSize(UINT nType, CSize)
     113        {
     114                if(nType != SIZE_MINIMIZED)
     115                        if(m_pVmrWindowlessControl)
     116                        {
     117                                CRect VideoPosition = GetVideoPosition();
     118                                const HRESULT nSetVideoPositionResult = m_pVmrWindowlessControl->SetVideoPosition(NULL, &VideoPosition);
     119                                _Z4(atlTraceUI, SUCCEEDED(nSetVideoPositionResult) ? 6 : 4, _T("nSetVideoPositionResult 0x%08x\n"), nSetVideoPositionResult);
     120                        }
     121                return 0;
     122        }
     123        LRESULT OnLButtonDblClk(UINT, CPoint Position)
     124        {
     125                COlePropertyFrameDialog Dialog;
     126                Dialog.SetObject(m_pBaseFilter);
     127                Dialog.SetObjectPages();
     128                Dialog.DoModal(m_hWnd);
     129                return 0;
     130        }
     131};
    17132
    18133////////////////////////////////////////////////////////////
     
    418533                                REFERENCE_TIME nPositionC = nField1Time % g_nPeriod;
    419534                                LONG nPositionD = (LONG) (abs((g_nPeriod / 2) - nPositionC) * (600 - 60) / (g_nPeriod / 2));
    420                                 Paint(pnData + nFirstRowOffset + (40 + 0) * nNextRowOffset + (60 + nPositionD) * 2, nNextRowOffset, 0xFF); // Change color to 0x00 to distinguish between the fields
     535                                Paint(pnData + nFirstRowOffset + (40 + 0) * nNextRowOffset + (60 + nPositionD) * 2, nNextRowOffset, GetFilter()->GetColorize() ? 0x00 : 0xFF);
    421536                                if(GetFilter()->GetWeave())
    422537                                        OutputProperties.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
     
    432547                CMediaType m_pRequestedMediaType;
    433548                BOOL m_bWeave;
     549                BOOL m_bColorize;
    434550
    435551        public:
     
    437553                CSourceFilter() throw() :
    438554                        CBasePersistT<CSourceFilter>(GetDataCriticalSection()),
    439                         m_bWeave(FALSE)
     555                        m_bWeave(FALSE),
     556                        m_bColorize(FALSE)
    440557                {
    441558                        _Z4(atlTraceRefcount, 4, _T("this 0x%p\n"), this);
     
    540657                        m_bWeave = bWeave;
    541658                }
     659                BOOL GetColorize() const throw()
     660                {
     661                        CRoCriticalSectionLock DataLock(GetDataCriticalSection());
     662                        return m_bColorize;
     663                }
     664                VOID SetColorize(BOOL bColorize) throw()
     665                {
     666                        CRoCriticalSectionLock DataLock(GetDataCriticalSection());
     667                        m_bColorize = bColorize;
     668                }
    542669        };
    543670
     
    614741
    615742        ////////////////////////////////////////////////////
     743        // CVmr7PropertyPage
     744
     745        class CVmr7PropertyPage :
     746                public CPropertyPageT<CVmr7PropertyPage>,
     747                public CDialogResize<CVmr7PropertyPage>
     748        {
     749        public:
     750                enum { IDD = IDD_MAIN_VMR7 };
     751
     752        BEGIN_MSG_MAP_EX(CVmr7PropertyPage)
     753                CHAIN_MSG_MAP(CPropertyPageT<CVmr7PropertyPage>)
     754                CHAIN_MSG_MAP(CDialogResize<CVmr7PropertyPage>)
     755                MSG_WM_INITDIALOG(OnInitDialog)
     756                MSG_WM_DESTROY(OnDestroy)
     757                COMMAND_ID_HANDLER_EX(IDC_MAIN_VMR7_RUN, OnRunButtonClicked)
     758                COMMAND_ID_HANDLER_EX(IDC_MAIN_VMR7_PAUSE, OnPauseButtonClicked)
     759                COMMAND_ID_HANDLER_EX(IDC_MAIN_VMR7_STOP, OnStopButtonClicked)
     760                COMMAND_ID_HANDLER_EX(IDC_MAIN_VMR7_WEAVE, OnWeaveButtonClicked)
     761                COMMAND_ID_HANDLER_EX(IDC_MAIN_VMR7_COLORIZE, OnColorizeButtonClicked)
     762                MESSAGE_HANDLER_EX(WM_FILTERGRAPHEVENT, OnFilterGraphEvent)
     763                REFLECT_NOTIFICATIONS()
     764        END_MSG_MAP()
     765
     766        BEGIN_DLGRESIZE_MAP(CVmr7PropertyPage)
     767                DLGRESIZE_CONTROL(IDC_MAIN_VMR7_VIDEO, DLSZ_SIZE_X | DLSZ_SIZE_Y)
     768                DLGRESIZE_CONTROL(IDC_MAIN_VMR7_RUN, DLSZ_MOVE_X)
     769                DLGRESIZE_CONTROL(IDC_MAIN_VMR7_PAUSE, DLSZ_MOVE_X)
     770                DLGRESIZE_CONTROL(IDC_MAIN_VMR7_STOP, DLSZ_MOVE_X)
     771                DLGRESIZE_CONTROL(IDC_MAIN_VMR7_WEAVE, DLSZ_MOVE_Y)
     772                DLGRESIZE_CONTROL(IDC_MAIN_VMR7_COLORIZE, DLSZ_MOVE_Y)
     773        END_DLGRESIZE_MAP()
     774
     775        public:
     776
     777                ////////////////////////////////////////////////////////
     778                // Window Message Identifiers
     779
     780                enum
     781                {
     782                        WM_FIRST = WM_APP,
     783                        WM_FILTERGRAPHEVENT,
     784                };
     785
     786        private:
     787                CMainPropertySheet& m_Owner;
     788                CStatic m_VideoStatic;
     789                CGenericFilterGraph m_FilterGraph;
     790                CObjectPtr<CSourceFilter> m_pSourceFilter;
     791                CVmr7Window m_RendererWindow;
     792                CButton m_RunButton;
     793                CButton m_PauseButton;
     794                CButton m_StopButton;
     795                CButton m_WeaveButton;
     796                CButton m_ColorizeButton;
     797
     798                VOID UpdateControls()
     799                {
     800                        OAFilterState State;
     801                        if(SUCCEEDED(m_FilterGraph.m_pMediaControl->GetState(0, &State)))
     802                        {
     803                                m_RunButton.EnableWindow(State != State_Running);
     804                                m_PauseButton.EnableWindow(State != State_Paused);
     805                                m_StopButton.EnableWindow(State != State_Stopped);
     806                        } else
     807                        {
     808                                m_RunButton.EnableWindow(FALSE);
     809                                m_PauseButton.EnableWindow(FALSE);
     810                                m_StopButton.EnableWindow(FALSE);
     811                        }
     812                }
     813
     814        public:
     815        // CVmr7PropertyPage
     816                CVmr7PropertyPage(CMainPropertySheet* pOwner) :
     817                        m_Owner(*pOwner)
     818                {
     819                }
     820
     821        // CDialogResize
     822                VOID DlgResize_UpdateLayout(INT nWidth, INT nHeight)
     823                {
     824                        __super::DlgResize_UpdateLayout(nWidth, nHeight);
     825                        CRect VideoPosition;
     826                        _W(m_VideoStatic.GetWindowRect(VideoPosition));
     827                        _W(ScreenToClient(VideoPosition));
     828                        _W(m_RendererWindow.MoveWindow(VideoPosition));
     829                }
     830
     831        // Window Message Handelrs
     832                LRESULT OnInitDialog(HWND, LPARAM)
     833                {
     834                        m_VideoStatic = GetDlgItem(IDC_MAIN_VMR7_VIDEO);
     835                        m_VideoStatic.ShowWindow(SW_HIDE);
     836                        CRect VideoPosition;
     837                        _W(m_VideoStatic.GetWindowRect(VideoPosition));
     838                        _W(ScreenToClient(VideoPosition));
     839                        m_RunButton = GetDlgItem(IDC_MAIN_VMR7_RUN);
     840                        m_PauseButton = GetDlgItem(IDC_MAIN_VMR7_PAUSE);
     841                        m_StopButton = GetDlgItem(IDC_MAIN_VMR7_STOP);
     842                        m_WeaveButton = GetDlgItem(IDC_MAIN_VMR7_WEAVE);
     843                        m_ColorizeButton = GetDlgItem(IDC_MAIN_VMR7_COLORIZE);
     844                        DlgResize_Init(TRUE);
     845                        m_FilterGraph.CoCreateInstance();
     846                        CObjectPtr<CAmGraphBuilderCallback> pAmGraphBuilderCallback;
     847                        pAmGraphBuilderCallback.Construct();
     848                        pAmGraphBuilderCallback->SetGraphBuilder(m_FilterGraph.m_pFilterGraph);
     849                        const CComPtr<IBaseFilter> pBaseFilter = m_RendererWindow.CoCreateBaseFilterInstance();
     850                        __C(m_FilterGraph->AddFilter(pBaseFilter, CT2CW(_T("VMR-7"))));
     851                        m_RendererWindow.Create(m_hWnd);
     852                        _W(m_RendererWindow.MoveWindow(VideoPosition));
     853                        m_RendererWindow.ShowWindow(SW_SHOWNORMAL);
     854                        m_RendererWindow.Initialize(pBaseFilter);
     855                        CObjectPtr<CSourceFilter> pSourceFilter;
     856                        pSourceFilter.Construct()->Initialize();
     857                        pSourceFilter->SetWeave(m_WeaveButton.GetCheck());
     858                        pSourceFilter->SetColorize(m_ColorizeButton.GetCheck());
     859                        m_pSourceFilter = pSourceFilter;
     860                        __C(m_FilterGraph->AddFilter(pSourceFilter, CT2CW(_T("Source"))));
     861                        __C(m_FilterGraph->Connect(pSourceFilter->GetOutputPin(), _FilterGraphHelper::GetFilterPin(m_RendererWindow.m_pBaseFilter)));
     862                        __C(m_FilterGraph.m_pMediaEventEx->SetNotifyWindow((OAHWND) m_hWnd, WM_FILTERGRAPHEVENT, (LONG_PTR) this));
     863                        UpdateControls();
     864                        return 0;
     865                }
     866                LRESULT OnDestroy() throw()
     867                {
     868                        if(m_FilterGraph.m_pMediaControl)
     869                                _V(m_FilterGraph.m_pMediaControl->Stop());
     870                        m_RendererWindow.Terminate();
     871                        m_pSourceFilter.Release();
     872                        m_FilterGraph.Release();
     873                        return 0;
     874                }
     875                LRESULT OnRunButtonClicked(UINT, INT, HWND)
     876                {
     877                        CWaitCursor WaitCursor;
     878                        __D(m_FilterGraph.m_pMediaControl, E_NOINTERFACE);
     879                        __C(m_FilterGraph.m_pMediaControl->Run());
     880                        UpdateControls();
     881                        #pragma region Capabilities
     882                        _ATLTRY
     883                        {
     884                                const CComQIPtr<IVMRDeinterlaceControl> pVmrDeinterlaceControl = m_RendererWindow.m_pBaseFilter;
     885                                VMRVideoDesc VideoDescription;
     886                                ZeroMemory(&VideoDescription, sizeof VideoDescription);
     887                                VideoDescription.dwSize = sizeof VideoDescription;
     888                                const CVideoInfoHeader2* pVideoInfoHeader2 = m_pSourceFilter->GetRequestedMediaType().GetVideoInfoHeader2();
     889                                _A(pVideoInfoHeader2);
     890                                const CSize Extent = pVideoInfoHeader2->GetExtent();
     891                                VideoDescription.dwSampleWidth = Extent.cx;
     892                                VideoDescription.dwSampleHeight = Extent.cy;
     893                                VideoDescription.SingleFieldPerSample = FALSE;
     894                                VideoDescription.dwFourCC = pVideoInfoHeader2->GetBitmapInfoHeader().biCompression;
     895                                VideoDescription.InputSampleFreq.dwNumerator = 30000;
     896                                VideoDescription.InputSampleFreq.dwDenominator = 1001;
     897                                VideoDescription.OutputFrameFreq.dwNumerator = 60000;
     898                                VideoDescription.OutputFrameFreq.dwDenominator = 1001;
     899                                DWORD nModeCount = 16;
     900                                CTempBufferT<GUID> pModes(nModeCount);
     901                                const HRESULT nGetNumberOfDeinterlaceModesResult = pVmrDeinterlaceControl->GetNumberOfDeinterlaceModes(&VideoDescription, &nModeCount, pModes);
     902                                _Z4(atlTraceGeneral, 4, _T("nGetNumberOfDeinterlaceModesResult 0x%08x, nModeCount %d\n"), nGetNumberOfDeinterlaceModesResult, nModeCount);
     903                                if(SUCCEEDED(nGetNumberOfDeinterlaceModesResult))
     904                                {
     905                                        for(DWORD nModeIndex = 0; nModeIndex < nModeCount; nModeIndex++)
     906                                        {
     907                                                const GUID& Mode = pModes[nModeIndex];
     908                                                _Z4(atlTraceGeneral, 4, _T("nModeIndex %d, Mode %s\n"), nModeIndex, FormatDeinterlaceMode(Mode));
     909                                                VMRDeinterlaceCaps Capabilities;
     910                                                ZeroMemory(&Capabilities, sizeof Capabilities);
     911                                                Capabilities.dwSize = sizeof Capabilities;
     912                                                const HRESULT nGetDeinterlaceModeCapsResult = pVmrDeinterlaceControl->GetDeinterlaceModeCaps(const_cast<GUID*>(&Mode), &VideoDescription, &Capabilities);
     913                                                _Z4(atlTraceGeneral, 4, _T("nGetDeinterlaceModeCapsResult 0x%08x, Capabilities.dwNumPreviousOutputFrames %d, .dwNumForwardRefSamples %d, .dwNumBackwardRefSamples %d, .DeinterlaceTechnology 0x%x\n"), nGetDeinterlaceModeCapsResult, Capabilities.dwNumPreviousOutputFrames, Capabilities.dwNumForwardRefSamples, Capabilities.dwNumBackwardRefSamples, Capabilities.DeinterlaceTechnology);
     914                                        }
     915                                }
     916                                GUID DeinterlaceMode = GUID_NULL;
     917                                const HRESULT nGetDeinterlaceModeResult = pVmrDeinterlaceControl->GetDeinterlaceMode(0, &DeinterlaceMode);
     918                                _Z4(atlTraceGeneral, 4, _T("nGetDeinterlaceModeResult 0x%08x\n"), nGetDeinterlaceModeResult);
     919                                if(SUCCEEDED(nGetDeinterlaceModeResult) && !(nGetDeinterlaceModeResult == S_FALSE && DeinterlaceMode == GUID_NULL))
     920                                        _Z4(atlTraceGeneral, 4, _T("DeinterlaceMode %s\n"), FormatDeinterlaceMode(DeinterlaceMode));
     921                                DWORD nPreferences = 0;
     922                                const HRESULT nGetDeinterlacePrefsResult = pVmrDeinterlaceControl->GetDeinterlacePrefs(&nPreferences);
     923                                _Z4(atlTraceGeneral, 4, _T("nGetDeinterlacePrefsResult 0x%08x, nPreferences 0x%x\n"), nGetDeinterlacePrefsResult, nPreferences);
     924                                GUID ActualDeinterlaceMode;
     925                                const HRESULT nGetActualDeinterlaceModeResult = pVmrDeinterlaceControl->GetActualDeinterlaceMode(0, &ActualDeinterlaceMode);
     926                                _Z4(atlTraceGeneral, 4, _T("nGetActualDeinterlaceModeResult 0x%08x\n"), nGetActualDeinterlaceModeResult);
     927                                if(SUCCEEDED(nGetActualDeinterlaceModeResult))
     928                                        _Z4(atlTraceGeneral, 4, _T("ActualDeinterlaceMode %s\n"), FormatDeinterlaceMode(ActualDeinterlaceMode));
     929                        }
     930                        _ATLCATCHALL()
     931                        {
     932                                _Z_EXCEPTION();
     933                        }
     934                        #pragma endregion
     935                        return 0;
     936                }
     937                LRESULT OnPauseButtonClicked(UINT, INT, HWND)
     938                {
     939                        CWaitCursor WaitCursor;
     940                        __D(m_FilterGraph.m_pMediaControl, E_NOINTERFACE);
     941                        __C(m_FilterGraph.m_pMediaControl->Pause());
     942                        UpdateControls();
     943                        return 0;
     944                }
     945                LRESULT OnStopButtonClicked(UINT, INT, HWND)
     946                {
     947                        CWaitCursor WaitCursor;
     948                        if(m_FilterGraph.m_pMediaControl)
     949                                _V(m_FilterGraph.m_pMediaControl->Stop());
     950                        UpdateControls();
     951                        return 0;
     952                }
     953                LRESULT OnWeaveButtonClicked(UINT, INT, HWND)
     954                {
     955                        if(m_pSourceFilter)
     956                                m_pSourceFilter->SetWeave(m_WeaveButton.GetCheck());
     957                        return 0;
     958                }
     959                LRESULT OnColorizeButtonClicked(UINT, INT, HWND)
     960                {
     961                        if(m_pSourceFilter)
     962                                m_pSourceFilter->SetColorize(m_ColorizeButton.GetCheck());
     963                        return 0;
     964                }
     965                LRESULT OnFilterGraphEvent(UINT, WPARAM, LPARAM)
     966                {
     967                        if(!m_FilterGraph.m_pMediaEventEx)
     968                                return 0;
     969                        _ATLTRY
     970                        {
     971                                for(; ; )
     972                                {
     973                                        LONG nEventCode;
     974                                        LONG_PTR nParameter1, nParameter2;
     975                                        const HRESULT nGetEventResult = m_FilterGraph.m_pMediaEventEx->GetEvent(&nEventCode, &nParameter1, &nParameter2, 0);
     976                                        if(nGetEventResult == E_ABORT)
     977                                                break;
     978                                        __C(nGetEventResult);
     979                                        _ATLTRY
     980                                        {
     981                                                switch(nEventCode)
     982                                                {
     983                                                case EC_ERRORABORT:
     984                                                        _Z2(atlTraceGeneral, 2, _T("nEventCode EC_ERRORABORT 0x%02X, nParameter1 0x%08x, nParameter2 0x%08x\n"), nEventCode, nParameter1, nParameter2);
     985                                                        _A(FAILED(nParameter1));
     986                                                        AtlMessageBoxEx(m_hWnd, (LPCTSTR) AtlFormatString(_T("EC_ERRORABORT Event: %s."), AtlFormatSystemMessage((HRESULT) nParameter1).TrimRight(_T("\t\n\r ."))), IDS_ERROR, MB_ICONERROR | MB_OK);
     987                                                        break;
     988                                                default:
     989                                                        _Z1(atlTraceGeneral, 1, _T("nEventCode 0x%02X, nParameter1 0x%08x, nParameter2 0x%08x\n"), nEventCode, nParameter1, nParameter2);
     990                                                }
     991                                        }
     992                                        _ATLCATCHALL()
     993                                        {
     994                                                _V(m_FilterGraph.m_pMediaEventEx->FreeEventParams(nEventCode, nParameter1, nParameter2));
     995                                                _ATLRETHROW;
     996                                        }
     997                                        _V(m_FilterGraph.m_pMediaEventEx->FreeEventParams(nEventCode, nParameter1, nParameter2));
     998                                }
     999                        }
     1000                        _ATLCATCHALL()
     1001                        {
     1002                                _Z_EXCEPTION();
     1003                        }
     1004                        return 0;
     1005                }
     1006                INT OnKillActive()
     1007                {
     1008                        m_StopButton.Click();
     1009                        return 0;
     1010                }
     1011        };
     1012
     1013        ////////////////////////////////////////////////////
    6161014        // CVmr9PropertyPage
    6171015
     
    6321030                COMMAND_ID_HANDLER_EX(IDC_MAIN_VMR9_STOP, OnStopButtonClicked)
    6331031                COMMAND_ID_HANDLER_EX(IDC_MAIN_VMR9_WEAVE, OnWeaveButtonClicked)
     1032                COMMAND_ID_HANDLER_EX(IDC_MAIN_VMR9_COLORIZE, OnColorizeButtonClicked)
    6341033                MESSAGE_HANDLER_EX(WM_FILTERGRAPHEVENT, OnFilterGraphEvent)
    6351034                REFLECT_NOTIFICATIONS()
     
    6421041                DLGRESIZE_CONTROL(IDC_MAIN_VMR9_STOP, DLSZ_MOVE_X)
    6431042                DLGRESIZE_CONTROL(IDC_MAIN_VMR9_WEAVE, DLSZ_MOVE_Y)
     1043                DLGRESIZE_CONTROL(IDC_MAIN_VMR9_COLORIZE, DLSZ_MOVE_Y)
    6441044        END_DLGRESIZE_MAP()
    6451045
     
    6651065                CButton m_StopButton;
    6661066                CButton m_WeaveButton;
     1067                CButton m_ColorizeButton;
    6671068
    6681069                VOID UpdateControls()
     
    7111112                        m_StopButton = GetDlgItem(IDC_MAIN_VMR9_STOP);
    7121113                        m_WeaveButton = GetDlgItem(IDC_MAIN_VMR9_WEAVE);
     1114                        m_ColorizeButton = GetDlgItem(IDC_MAIN_VMR9_WEAVE);
    7131115                        DlgResize_Init(TRUE);
    7141116                        m_FilterGraph.CoCreateInstance();
     
    7251127                        pSourceFilter.Construct()->Initialize();
    7261128                        pSourceFilter->SetWeave(m_WeaveButton.GetCheck());
     1129                        pSourceFilter->SetColorize(m_ColorizeButton.GetCheck());
    7271130                        m_pSourceFilter = pSourceFilter;
    7281131                        __C(m_FilterGraph->AddFilter(pSourceFilter, CT2CW(_T("Source"))));
     
    8251228                        return 0;
    8261229                }
     1230                LRESULT OnColorizeButtonClicked(UINT, INT, HWND)
     1231                {
     1232                        if(m_pSourceFilter)
     1233                                m_pSourceFilter->SetColorize(m_ColorizeButton.GetCheck());
     1234                        return 0;
     1235                }
    8271236                LRESULT OnFilterGraphEvent(UINT, WPARAM, LPARAM)
    8281237                {
     
    8661275                        return 0;
    8671276                }
     1277                INT OnKillActive()
     1278                {
     1279                        m_StopButton.Click();
     1280                        return 0;
     1281                }
    8681282        };
    8691283
     1284        ////////////////////////////////////////////////////
     1285        // CEvrPropertyPage
     1286
     1287        class CEvrPropertyPage :
     1288                public CPropertyPageT<CEvrPropertyPage>,
     1289                public CDialogResize<CEvrPropertyPage>
     1290        {
     1291        public:
     1292                enum { IDD = IDD_MAIN_EVR };
     1293
     1294        BEGIN_MSG_MAP_EX(CEvrPropertyPage)
     1295                CHAIN_MSG_MAP(CPropertyPageT<CEvrPropertyPage>)
     1296                CHAIN_MSG_MAP(CDialogResize<CEvrPropertyPage>)
     1297                MSG_WM_INITDIALOG(OnInitDialog)
     1298                MSG_WM_DESTROY(OnDestroy)
     1299                COMMAND_ID_HANDLER_EX(IDC_MAIN_EVR_RUN, OnRunButtonClicked)
     1300                COMMAND_ID_HANDLER_EX(IDC_MAIN_EVR_PAUSE, OnPauseButtonClicked)
     1301                COMMAND_ID_HANDLER_EX(IDC_MAIN_EVR_STOP, OnStopButtonClicked)
     1302                COMMAND_ID_HANDLER_EX(IDC_MAIN_EVR_WEAVE, OnWeaveButtonClicked)
     1303                COMMAND_ID_HANDLER_EX(IDC_MAIN_EVR_COLORIZE, OnColorizeButtonClicked)
     1304                MESSAGE_HANDLER_EX(WM_FILTERGRAPHEVENT, OnFilterGraphEvent)
     1305                REFLECT_NOTIFICATIONS()
     1306        END_MSG_MAP()
     1307
     1308        BEGIN_DLGRESIZE_MAP(CEvrPropertyPage)
     1309                DLGRESIZE_CONTROL(IDC_MAIN_EVR_VIDEO, DLSZ_SIZE_X | DLSZ_SIZE_Y)
     1310                DLGRESIZE_CONTROL(IDC_MAIN_EVR_RUN, DLSZ_MOVE_X)
     1311                DLGRESIZE_CONTROL(IDC_MAIN_EVR_PAUSE, DLSZ_MOVE_X)
     1312                DLGRESIZE_CONTROL(IDC_MAIN_EVR_STOP, DLSZ_MOVE_X)
     1313                DLGRESIZE_CONTROL(IDC_MAIN_EVR_WEAVE, DLSZ_MOVE_Y)
     1314                DLGRESIZE_CONTROL(IDC_MAIN_EVR_COLORIZE, DLSZ_MOVE_Y)
     1315        END_DLGRESIZE_MAP()
     1316
     1317        public:
     1318
     1319                ////////////////////////////////////////////////////////
     1320                // Window Message Identifiers
     1321
     1322                enum
     1323                {
     1324                        WM_FIRST = WM_APP,
     1325                        WM_FILTERGRAPHEVENT,
     1326                };
     1327
     1328        private:
     1329                CMainPropertySheet& m_Owner;
     1330                CStatic m_VideoStatic;
     1331                CGenericFilterGraph m_FilterGraph;
     1332                CObjectPtr<CSourceFilter> m_pSourceFilter;
     1333                CEvrWindow m_RendererWindow;
     1334                CButton m_RunButton;
     1335                CButton m_PauseButton;
     1336                CButton m_StopButton;
     1337                CButton m_WeaveButton;
     1338                CButton m_ColorizeButton;
     1339
     1340                VOID UpdateControls()
     1341                {
     1342                        OAFilterState State;
     1343                        if(SUCCEEDED(m_FilterGraph.m_pMediaControl->GetState(0, &State)))
     1344                        {
     1345                                m_RunButton.EnableWindow(State != State_Running);
     1346                                m_PauseButton.EnableWindow(State != State_Paused);
     1347                                m_StopButton.EnableWindow(State != State_Stopped);
     1348                        } else
     1349                        {
     1350                                m_RunButton.EnableWindow(FALSE);
     1351                                m_PauseButton.EnableWindow(FALSE);
     1352                                m_StopButton.EnableWindow(FALSE);
     1353                        }
     1354                }
     1355
     1356        public:
     1357        // CEvrPropertyPage
     1358                CEvrPropertyPage(CMainPropertySheet* pOwner) :
     1359                        m_Owner(*pOwner)
     1360                {
     1361                }
     1362
     1363        // CDialogResize
     1364                VOID DlgResize_UpdateLayout(INT nWidth, INT nHeight)
     1365                {
     1366                        __super::DlgResize_UpdateLayout(nWidth, nHeight);
     1367                        CRect VideoPosition;
     1368                        _W(m_VideoStatic.GetWindowRect(VideoPosition));
     1369                        _W(ScreenToClient(VideoPosition));
     1370                        _W(m_RendererWindow.MoveWindow(VideoPosition));
     1371                }
     1372
     1373        // Window Message Handelrs
     1374                LRESULT OnInitDialog(HWND, LPARAM)
     1375                {
     1376                        m_VideoStatic = GetDlgItem(IDC_MAIN_EVR_VIDEO);
     1377                        m_VideoStatic.ShowWindow(SW_HIDE);
     1378                        CRect VideoPosition;
     1379                        _W(m_VideoStatic.GetWindowRect(VideoPosition));
     1380                        _W(ScreenToClient(VideoPosition));
     1381                        m_RunButton = GetDlgItem(IDC_MAIN_EVR_RUN);
     1382                        m_PauseButton = GetDlgItem(IDC_MAIN_EVR_PAUSE);
     1383                        m_StopButton = GetDlgItem(IDC_MAIN_EVR_STOP);
     1384                        m_WeaveButton = GetDlgItem(IDC_MAIN_EVR_WEAVE);
     1385                        m_ColorizeButton = GetDlgItem(IDC_MAIN_EVR_COLORIZE);
     1386                        DlgResize_Init(TRUE);
     1387                        m_FilterGraph.CoCreateInstance();
     1388                        CObjectPtr<CAmGraphBuilderCallback> pAmGraphBuilderCallback;
     1389                        pAmGraphBuilderCallback.Construct();
     1390                        pAmGraphBuilderCallback->SetGraphBuilder(m_FilterGraph.m_pFilterGraph);
     1391                        const CComPtr<IBaseFilter> pBaseFilter = m_RendererWindow.CoCreateBaseFilterInstance();
     1392                        __C(m_FilterGraph->AddFilter(pBaseFilter, CT2CW(_T("EVR"))));
     1393                        m_RendererWindow.Create(m_hWnd);
     1394                        _W(m_RendererWindow.MoveWindow(VideoPosition));
     1395                        m_RendererWindow.ShowWindow(SW_SHOWNORMAL);
     1396                        m_RendererWindow.Initialize(pBaseFilter);
     1397                        CObjectPtr<CSourceFilter> pSourceFilter;
     1398                        pSourceFilter.Construct()->Initialize();
     1399                        pSourceFilter->SetWeave(m_WeaveButton.GetCheck());
     1400                        pSourceFilter->SetColorize(m_ColorizeButton.GetCheck());
     1401                        m_pSourceFilter = pSourceFilter;
     1402                        __C(m_FilterGraph->AddFilter(pSourceFilter, CT2CW(_T("Source"))));
     1403                        __C(m_FilterGraph->Connect(pSourceFilter->GetOutputPin(), _FilterGraphHelper::GetFilterPin(m_RendererWindow.m_pBaseFilter)));
     1404                        __C(m_FilterGraph.m_pMediaEventEx->SetNotifyWindow((OAHWND) m_hWnd, WM_FILTERGRAPHEVENT, (LONG_PTR) this));
     1405                        UpdateControls();
     1406                        return 0;
     1407                }
     1408                LRESULT OnDestroy() throw()
     1409                {
     1410                        if(m_FilterGraph.m_pMediaControl)
     1411                                _V(m_FilterGraph.m_pMediaControl->Stop());
     1412                        m_RendererWindow.Terminate();
     1413                        m_pSourceFilter.Release();
     1414                        m_FilterGraph.Release();
     1415                        return 0;
     1416                }
     1417                LRESULT OnRunButtonClicked(UINT, INT, HWND)
     1418                {
     1419                        CWaitCursor WaitCursor;
     1420                        __D(m_FilterGraph.m_pMediaControl, E_NOINTERFACE);
     1421                        __C(m_FilterGraph.m_pMediaControl->Run());
     1422                        UpdateControls();
     1423                        #pragma region Capabilities
     1424                        _ATLTRY
     1425                        {
     1426                                // TODO: IMFVideoProcessor
     1427                        }
     1428                        _ATLCATCHALL()
     1429                        {
     1430                                _Z_EXCEPTION();
     1431                        }
     1432                        #pragma endregion
     1433                        return 0;
     1434                }
     1435                LRESULT OnPauseButtonClicked(UINT, INT, HWND)
     1436                {
     1437                        CWaitCursor WaitCursor;
     1438                        __D(m_FilterGraph.m_pMediaControl, E_NOINTERFACE);
     1439                        __C(m_FilterGraph.m_pMediaControl->Pause());
     1440                        UpdateControls();
     1441                        return 0;
     1442                }
     1443                LRESULT OnStopButtonClicked(UINT, INT, HWND)
     1444                {
     1445                        CWaitCursor WaitCursor;
     1446                        if(m_FilterGraph.m_pMediaControl)
     1447                                _V(m_FilterGraph.m_pMediaControl->Stop());
     1448                        UpdateControls();
     1449                        return 0;
     1450                }
     1451                LRESULT OnWeaveButtonClicked(UINT, INT, HWND)
     1452                {
     1453                        if(m_pSourceFilter)
     1454                                m_pSourceFilter->SetWeave(m_WeaveButton.GetCheck());
     1455                        return 0;
     1456                }
     1457                LRESULT OnColorizeButtonClicked(UINT, INT, HWND)
     1458                {
     1459                        if(m_pSourceFilter)
     1460                                m_pSourceFilter->SetColorize(m_ColorizeButton.GetCheck());
     1461                        return 0;
     1462                }
     1463                LRESULT OnFilterGraphEvent(UINT, WPARAM, LPARAM)
     1464                {
     1465                        if(!m_FilterGraph.m_pMediaEventEx)
     1466                                return 0;
     1467                        _ATLTRY
     1468                        {
     1469                                for(; ; )
     1470                                {
     1471                                        LONG nEventCode;
     1472                                        LONG_PTR nParameter1, nParameter2;
     1473                                        const HRESULT nGetEventResult = m_FilterGraph.m_pMediaEventEx->GetEvent(&nEventCode, &nParameter1, &nParameter2, 0);
     1474                                        if(nGetEventResult == E_ABORT)
     1475                                                break;
     1476                                        __C(nGetEventResult);
     1477                                        _ATLTRY
     1478                                        {
     1479                                                switch(nEventCode)
     1480                                                {
     1481                                                case EC_ERRORABORT:
     1482                                                        _Z2(atlTraceGeneral, 2, _T("nEventCode EC_ERRORABORT 0x%02X, nParameter1 0x%08x, nParameter2 0x%08x\n"), nEventCode, nParameter1, nParameter2);
     1483                                                        _A(FAILED(nParameter1));
     1484                                                        AtlMessageBoxEx(m_hWnd, (LPCTSTR) AtlFormatString(_T("EC_ERRORABORT Event: %s."), AtlFormatSystemMessage((HRESULT) nParameter1).TrimRight(_T("\t\n\r ."))), IDS_ERROR, MB_ICONERROR | MB_OK);
     1485                                                        break;
     1486                                                default:
     1487                                                        _Z1(atlTraceGeneral, 1, _T("nEventCode 0x%02X, nParameter1 0x%08x, nParameter2 0x%08x\n"), nEventCode, nParameter1, nParameter2);
     1488                                                }
     1489                                        }
     1490                                        _ATLCATCHALL()
     1491                                        {
     1492                                                _V(m_FilterGraph.m_pMediaEventEx->FreeEventParams(nEventCode, nParameter1, nParameter2));
     1493                                                _ATLRETHROW;
     1494                                        }
     1495                                        _V(m_FilterGraph.m_pMediaEventEx->FreeEventParams(nEventCode, nParameter1, nParameter2));
     1496                                }
     1497                        }
     1498                        _ATLCATCHALL()
     1499                        {
     1500                                _Z_EXCEPTION();
     1501                        }
     1502                        return 0;
     1503                }
     1504                INT OnKillActive()
     1505                {
     1506                        m_StopButton.Click();
     1507                        return 0;
     1508                }
     1509        };
     1510
    8701511public:
     1512        CVmr7PropertyPage m_Vmr7PropertyPage;
    8711513        CVmr9PropertyPage m_Vmr9PropertyPage;
     1514        CEvrPropertyPage m_EvrPropertyPage;
    8721515
    8731516public:
     
    8751518        CMainPropertySheet() :
    8761519                CSizablePropertySheetT<CMainPropertySheet>(_T("Render Interlaced Video")),
    877                 m_Vmr9PropertyPage(this)
    878         {
     1520                m_Vmr7PropertyPage(this),
     1521                m_Vmr9PropertyPage(this),
     1522                m_EvrPropertyPage(this)
     1523        {
     1524                AddPage(m_Vmr7PropertyPage);
    8791525                AddPage(m_Vmr9PropertyPage);
     1526                AddPage(m_EvrPropertyPage);
    8801527        }
    8811528        BOOL SetInitialPosition()
  • trunk/Utilities/RenderInterlacedVideo/RenderInterlacedVideo_i.c

    r74 r75  
    77
    88 /* File created by MIDL compiler version 7.00.0555 */
    9 /* at Sun Jul 15 14:03:57 2012
     9/* at Sun Jul 15 14:15:39 2012
    1010 */
    1111/* Compiler settings for RenderInterlacedVideo.idl:
  • trunk/Utilities/RenderInterlacedVideo/RenderInterlacedVideo_i.h

    r74 r75  
    55
    66 /* File created by MIDL compiler version 7.00.0555 */
    7 /* at Sun Jul 15 14:03:57 2012
     7/* at Sun Jul 15 14:15:39 2012
    88 */
    99/* Compiler settings for RenderInterlacedVideo.idl:
Note: See TracChangeset for help on using the changeset viewer.