diff options
author | Casimir666 <casimir666@users.sourceforge.net> | 2009-04-18 21:39:19 +0400 |
---|---|---|
committer | Casimir666 <casimir666@users.sourceforge.net> | 2009-04-18 21:39:19 +0400 |
commit | 530c6354edabdd19d45d883fee88793664170adf (patch) | |
tree | d1fcf2a4b371465f0c20201a52f33db6367688e7 /src/apps | |
parent | f39d30c0b2eba6db09f1d3f66be6fd1eb2d7f5a5 (diff) |
Changed : merge with Beliyaal branch
Added : support for madVR (new Video Renderer)
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1048 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/apps')
80 files changed, 5170 insertions, 774 deletions
diff --git a/src/apps/ShuttlePN31/Common/Interface.c b/src/apps/ShuttlePN31/Common/Interface.c index 3b9fd91fb..9dce52c6a 100644 --- a/src/apps/ShuttlePN31/Common/Interface.c +++ b/src/apps/ShuttlePN31/Common/Interface.c @@ -1,4 +1,5 @@ #include <stdio.h> /* for NULL */
+#include <memory.h>
#include "Interface.h"
PN31_KEYCODE g_PN31Keyboard[] = {
diff --git a/src/apps/ShuttlePN31/Common/ShuttlePN31Client.cpp b/src/apps/ShuttlePN31/Common/ShuttlePN31Client.cpp index 8be7f1dd3..5480a09da 100644 --- a/src/apps/ShuttlePN31/Common/ShuttlePN31Client.cpp +++ b/src/apps/ShuttlePN31/Common/ShuttlePN31Client.cpp @@ -45,7 +45,7 @@ CMultiSz::CMultiSz(const CMultiSz& other) BYTE* CMultiSz::Realloc (BYTE* pBuff, DWORD nNewSize)
{
- BYTE* pNewBuff = new BYTE [nNewSize];
+ BYTE* pNewBuff = DNew BYTE [nNewSize];
memset (pNewBuff, 0, nNewSize);
if (pBuff) memcpy (pNewBuff, pBuff, min (m_MultiSzLen, nNewSize));
return pNewBuff;
@@ -412,7 +412,7 @@ CMultiSz CShuttlePN31Client::GetLowerFilters(HDEVINFO hDev, SP_DEVINFO_DATA* pDe if (BufferSize != 0)
{
// we allocate the proper buffer
- Buffer = new BYTE [BufferSize];
+ Buffer = DNew BYTE [BufferSize];
// we get the content of the buffer
diff --git a/src/apps/ShuttlePN31/Common/StdAfx.h b/src/apps/ShuttlePN31/Common/StdAfx.h index f6066e791..8c887cbb8 100644 --- a/src/apps/ShuttlePN31/Common/StdAfx.h +++ b/src/apps/ShuttlePN31/Common/StdAfx.h @@ -9,6 +9,7 @@ #if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
+#include "../../../DSUtil/SharedInclude.h"
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
diff --git a/src/apps/mplayerc/AllocatorCommon.h b/src/apps/mplayerc/AllocatorCommon.h index f7e6a2336..051bfa9b2 100644 --- a/src/apps/mplayerc/AllocatorCommon.h +++ b/src/apps/mplayerc/AllocatorCommon.h @@ -24,9 +24,9 @@ #pragma once
#define VMRBITMAP_UPDATE 0x80000000
-#define MAX_PICTURE_SLOTS (20+2) // Last 2 for pixels shader!
+#define MAX_PICTURE_SLOTS (60+2) // Last 2 for pixels shader!
-#define NB_JITTER 125
+#define NB_JITTER 126
namespace DSObjects
@@ -35,12 +35,39 @@ namespace DSObjects class CDX9AllocatorPresenter
: public ISubPicAllocatorPresenterImpl
{
+ public:
+ CCritSec m_VMR9AlphaBitmapLock;
+ void UpdateAlphaBitmap();
protected:
CSize m_ScreenSize;
UINT m_RefreshRate;
- bool m_fVMRSyncFix;
+// bool m_fVMRSyncFix;
+ bool m_bAlternativeVSync;
+ bool m_bHighColorResolution;
+ bool m_bCompositionEnabled;
+ bool m_bIsEVR;
+ int m_OrderedPaint;
+ int m_VSyncMode;
+ bool m_bDesktopCompositionDisabled;
+ bool m_bIsFullscreen;
+
+ CMPlayerCApp::Settings::CRendererSettingsEVR m_LastRendererSettings;
+
+ HRESULT (__stdcall * m_pDwmIsCompositionEnabled)(__out BOOL* pfEnabled);
+ HRESULT (__stdcall * m_pDwmEnableComposition)(UINT uCompositionAction);
+
+ HMODULE m_hDWMAPI;
+
+ HRESULT (__stdcall * m_pDirect3DCreate9Ex)(UINT SDKVersion, IDirect3D9Ex**);
+ HMODULE m_hD3D9;
+
+ CCritSec m_RenderLock;
+ CComPtr<IDirectDraw> m_pDirectDraw;
+ CComPtr<IDirect3D9Ex> m_pD3DEx;
CComPtr<IDirect3D9> m_pD3D;
+ CComPtr<IDirect3DDevice9Ex> m_pD3DDevEx;
+ CString m_D3DDevExError;
CComPtr<IDirect3DDevice9> m_pD3DDev;
CComPtr<IDirect3DTexture9> m_pVideoTexture[MAX_PICTURE_SLOTS];
CComPtr<IDirect3DSurface9> m_pVideoSurface[MAX_PICTURE_SLOTS];
@@ -48,23 +75,62 @@ namespace DSObjects CComPtr<IDirect3DSurface9> m_pOSDSurface;
CComPtr<ID3DXLine> m_pLine;
CComPtr<ID3DXFont> m_pFont;
- CInterfaceList<IDirect3DPixelShader9> m_pPixelShaders;
+ CComPtr<ID3DXSprite> m_pSprite;
+ class CExternalPixelShader
+ {
+ public:
+ CComPtr<IDirect3DPixelShader9> m_pPixelShader;
+ CStringA m_SourceData;
+ CStringA m_SourceTarget;
+ HRESULT Compile(CPixelShaderCompiler *pCompiler)
+ {
+ HRESULT hr = pCompiler->CompileShader(m_SourceData, "main", m_SourceTarget, 0, &m_pPixelShader);
+ if(FAILED(hr))
+ return hr;
+
+ return S_OK;
+ }
+ };
+ CAtlList<CExternalPixelShader> m_pPixelShaders;
+ CAtlList<CExternalPixelShader> m_pPixelShadersScreenSpace;
CComPtr<IDirect3DPixelShader9> m_pResizerPixelShader[3]; // bl, bc1, bc2
- CComPtr<IDirect3DTexture9> m_pResizerBicubic1stPass;
+ CComPtr<IDirect3DTexture9> m_pScreenSizeTemporaryTexture[2];
+ D3DFORMAT m_SurfaceType;
+ D3DFORMAT m_BackbufferType;
+ D3DFORMAT m_DisplayType;
D3DTEXTUREFILTERTYPE m_filter;
D3DCAPS9 m_caps;
CAutoPtr<CPixelShaderCompiler> m_pPSC;
- virtual HRESULT CreateDevice();
+ bool SettingsNeedResetDevice();
+
+ virtual HRESULT CreateDevice(CString &_Error);
+// virtual HRESULT AllocSurfaces(D3DFORMAT Format = D3DFMT_A2B10G10R10);
virtual HRESULT AllocSurfaces(D3DFORMAT Format = D3DFMT_A8R8G8B8);
virtual void DeleteSurfaces();
+ // Thread stuff
+ HANDLE m_hEvtQuit; // Stop rendering thread event
+ HANDLE m_hVSyncThread;
+ static DWORD WINAPI VSyncThreadStatic(LPVOID lpParam);
+ void VSyncThread();
+ void StartWorkerThreads();
+ void StopWorkerThreads();
+
UINT GetAdapter(IDirect3D9 *pD3D);
float m_bicubicA;
- HRESULT InitResizers(float bicubicA);
+ HRESULT InitResizers(float bicubicA, bool bNeedScreenSizeTexture);
+ bool GetVBlank(int &_ScanLine, int &_bInVBlank, bool _bMeasureTime);
+ bool WaitForVBlankRange(int &_RasterStart, int _RasterEnd, bool _bWaitIfInside, bool _bNeedAccurate, bool _bMeasure);
+ bool WaitForVBlank(bool &_Waited);
+ int GetVBlackPos();
+ void CalculateJitter(LONGLONG PerformanceCounter);
+ virtual void OnVBlankFinished(bool fAll, LONGLONG PerformanceCounter){}
+
+ HRESULT DrawRect(DWORD _Color, DWORD _Alpha, const CRect &_Rect);
HRESULT TextureCopy(CComPtr<IDirect3DTexture9> pTexture);
HRESULT TextureResize(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], D3DTEXTUREFILTERTYPE filter);
HRESULT TextureResizeBilinear(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4]);
@@ -101,30 +167,128 @@ namespace DSObjects LPD3DXFONT* ppFont);
+ void DrawText(const RECT &rc, const CString &strText, int _Priority);
void DrawStats();
HRESULT AlphaBlt(RECT* pSrc, RECT* pDst, CComPtr<IDirect3DTexture9> pTexture);
- virtual void OnResetDevice() {};
+ virtual void OnResetDevice() {};
+ virtual bool ResetDevice();
+
+ double GetFrameTime();
+ double GetFrameRate();
+
int m_nTearingPos;
VMR9AlphaBitmap m_VMR9AlphaBitmap;
+ CAutoVectorPtr<BYTE> m_VMR9AlphaBitmapData;
+ CRect m_VMR9AlphaBitmapRect;
+ int m_VMR9AlphaBitmapWidthBytes;
+
D3DXLoadSurfaceFromMemoryPtr m_pD3DXLoadSurfaceFromMemory;
D3DXCreateLinePtr m_pD3DXCreateLine;
D3DXCreateFontPtr m_pD3DXCreateFont;
+ HRESULT (__stdcall *m_pD3DXCreateSprite)(LPDIRECT3DDEVICE9 pDevice, LPD3DXSPRITE * ppSprite);
+
+
int m_nNbDXSurface; // Total number of DX Surfaces
+ int m_nVMR9Surfaces; // Total number of DX Surfaces
+ int m_iVMR9Surface;
int m_nCurSurface; // Surface currently displayed
long m_nUsedBuffer;
+ bool m_bNeedPendingResetDevice;
+ bool m_bPendingResetDevice;
double m_fAvrFps; // Estimate the real FPS
+ double m_fJitterStdDev; // Estimate the Jitter std dev
+ double m_fJitterMean;
+ double m_fSyncOffsetStdDev;
+ double m_fSyncOffsetAvr;
+ double m_DetectedRefreshRate;
+ double GetRefreshRate()
+ {
+ if (m_DetectedRefreshRate)
+ return m_DetectedRefreshRate;
+ else
+ return m_RefreshRate;
+ }
+
+ CCritSec m_RefreshRateLock;
+ double m_DetectedRefreshTime;
+ double m_DetectedRefreshTimePrim;
+ double m_DetectedScanlineTime;
+ double m_DetectedScanlineTimePrim;
+ double m_DetectedScanlinesPerFrame;
+ double m_ldDetectedRefreshRateList[100];
+ double m_ldDetectedScanlineRateList[100];
+ int m_DetectedRefreshRatePos;
+ bool m_bSyncStatsAvailable;
LONGLONG m_pllJitter [NB_JITTER]; // Jitter buffer for stats
+ LONGLONG m_pllSyncOffset [NB_JITTER]; // Jitter buffer for stats
LONGLONG m_llLastPerf;
+ LONGLONG m_JitterStdDev;
+ LONGLONG m_MaxJitter;
+ LONGLONG m_MinJitter;
+ LONGLONG m_MaxSyncOffset;
+ LONGLONG m_MinSyncOffset;
int m_nNextJitter;
+ int m_nNextSyncOffset;
REFERENCE_TIME m_rtTimePerFrame;
+ double m_DetectedFrameRate;
+ double m_DetectedFrameTime;
+ double m_DetectedFrameTimeStdDev;
+ bool m_DetectedLock;
+ LONGLONG m_DetectedFrameTimeHistory[60];
+ double m_DetectedFrameTimeHistoryHisotry[500];
+ int m_DetectedFrameTimePos;
+ int m_bInterlaced;
+
+ double m_TextScale;
+
+ int m_VBlankEndWait;
+ int m_VBlankStartWait;
+ LONGLONG m_VBlankWaitTime;
+ int m_VBlankMin;
+ int m_VBlankMinCalc;
+ int m_VBlankMax;
+ int m_VBlankEndPresent;
+ LONGLONG m_VBlankStartMeasureTime;
+ int m_VBlankStartMeasure;
+
+ LONGLONG m_PresentWaitTime;
+ LONGLONG m_PresentWaitTimeMin;
+ LONGLONG m_PresentWaitTimeMax;
+
+ LONGLONG m_PaintTime;
+ LONGLONG m_PaintTimeMin;
+ LONGLONG m_PaintTimeMax;
+
+ LONGLONG m_WaitForGPUTime;
+
+ LONGLONG m_RasterStatusWaitTime;
+ LONGLONG m_RasterStatusWaitTimeMin;
+ LONGLONG m_RasterStatusWaitTimeMax;
+ LONGLONG m_RasterStatusWaitTimeMaxCalc;
+
+ double m_ClockDiffCalc;
+ double m_ClockDiffPrim;
+ double m_ClockDiff;
+
+ double m_TimeChangeHisotry[100];
+ double m_ClockChangeHisotry[100];
+ int m_ClockTimeChangeHistoryPos;
+ double m_ModeratedTimeSpeed;
+ double m_ModeratedTimeSpeedPrim;
+ double m_ModeratedTimeSpeedDiff;
+
+ bool m_bCorrectedFrameTime;
+ int m_FrameTimeCorrection;
+ LONGLONG m_LastFrameDuration;
+ LONGLONG m_LastSampleTime;
CString m_strStatsMsg[10];
public:
- CDX9AllocatorPresenter(HWND hWnd, HRESULT& hr);
+ CDX9AllocatorPresenter(HWND hWnd, HRESULT& hr, bool bIsEVR, CString &_Error);
~CDX9AllocatorPresenter();
// ISubPicAllocatorPresenter
@@ -132,6 +296,7 @@ namespace DSObjects STDMETHODIMP_(bool) Paint(bool fAll);
STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget);
+ STDMETHODIMP SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace);
};
class CVMR9AllocatorPresenter
@@ -144,14 +309,14 @@ namespace DSObjects CComPtr<IVMRSurfaceAllocatorNotify9> m_pIVMRSurfAllocNotify;
CInterfaceArray<IDirect3DSurface9> m_pSurfaces;
- HRESULT CreateDevice();
+ HRESULT CreateDevice(CString &_Error);
void DeleteSurfaces();
bool m_fUseInternalTimer;
REFERENCE_TIME m_rtPrevStart;
public:
- CVMR9AllocatorPresenter(HWND hWnd, HRESULT& hr);
+ CVMR9AllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error);
DECLARE_IUNKNOWN
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
@@ -202,7 +367,7 @@ namespace DSObjects void DeleteSurfaces();
public:
- CRM9AllocatorPresenter(HWND hWnd, HRESULT& hr);
+ CRM9AllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error);
DECLARE_IUNKNOWN
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
@@ -227,7 +392,7 @@ namespace DSObjects void DeleteSurfaces();
public:
- CQT9AllocatorPresenter(HWND hWnd, HRESULT& hr);
+ CQT9AllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error);
DECLARE_IUNKNOWN
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
@@ -293,7 +458,7 @@ namespace DSObjects CSize m_ScreenSize;
public:
- CDXRAllocatorPresenter(HWND hWnd, HRESULT& hr);
+ CDXRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error);
virtual ~CDXRAllocatorPresenter();
DECLARE_IUNKNOWN
diff --git a/src/apps/mplayerc/ChildView.cpp b/src/apps/mplayerc/ChildView.cpp index 334da524c..d392f397e 100644 --- a/src/apps/mplayerc/ChildView.cpp +++ b/src/apps/mplayerc/ChildView.cpp @@ -27,12 +27,6 @@ #include "MainFrm.h"
#include "libpng.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CChildView
diff --git a/src/apps/mplayerc/ComPropertySheet.cpp b/src/apps/mplayerc/ComPropertySheet.cpp index 05a9d0059..dbe729cba 100644 --- a/src/apps/mplayerc/ComPropertySheet.cpp +++ b/src/apps/mplayerc/ComPropertySheet.cpp @@ -71,14 +71,14 @@ IMPLEMENT_DYNAMIC(CComPropertySheet, CPropertySheet) CComPropertySheet::CComPropertySheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
: CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
- m_pSite = new CComPropertyPageSite(this);
+ m_pSite = DNew CComPropertyPageSite(this);
m_size.SetSize(0, 0);
}
CComPropertySheet::CComPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
: CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
- m_pSite = new CComPropertyPageSite(this);
+ m_pSite = DNew CComPropertyPageSite(this);
m_size.SetSize(0, 0);
}
@@ -150,7 +150,7 @@ bool CComPropertySheet::AddPage(IPropertyPage* pPage, IUnknown* pUnk) hr = pPage->GetPageInfo(&ppi);
m_size.cx = max(m_size.cx, ppi.size.cx);
m_size.cy = max(m_size.cy, ppi.size.cy);
- CAutoPtr<CComPropertyPage> p(new CComPropertyPage(pPage));
+ CAutoPtr<CComPropertyPage> p(DNew CComPropertyPage(pPage));
__super::AddPage(p);
m_pages.AddTail(p);
diff --git a/src/apps/mplayerc/ConvertDlg.cpp b/src/apps/mplayerc/ConvertDlg.cpp index af6420a6d..c26693f20 100644 --- a/src/apps/mplayerc/ConvertDlg.cpp +++ b/src/apps/mplayerc/ConvertDlg.cpp @@ -94,7 +94,7 @@ void CConvertDlg::AddFile(CString fn) UpdateData(FALSE);
}
- CTreeItemFile* t = new CTreeItemFile(fn, pBF, m_tree, NULL);
+ CTreeItemFile* t = DNew CTreeItemFile(fn, pBF, m_tree, NULL);
AddFilter(*t, pBF);
@@ -195,11 +195,11 @@ void CConvertDlg::AddFilter(HTREEITEM hTIParent, IBaseFilter* pBFParent) if(pBF == m_pMux)
{
- t = new CTreeItemPin(pPin, m_tree, hTIParent);
+ t = DNew CTreeItemPin(pPin, m_tree, hTIParent);
}
else
{
- t = new CTreeItemFilter(pBF, m_tree, hTIParent);
+ t = DNew CTreeItemFilter(pBF, m_tree, hTIParent);
AddFilter(*t, pBF);
}
}
@@ -233,7 +233,7 @@ void CConvertDlg::AddFilter(HTREEITEM hTIParent, IBaseFilter* pBFParent) }
}
- CTreeItem* t2 = new CTreeItemResourceFolder(m_tree, hTIParent);
+ CTreeItem* t2 = DNew CTreeItemResourceFolder(m_tree, hTIParent);
if(CComQIPtr<IDSMResourceBag> pRB = pBFParent)
{
for(DWORD i = 0, cnt = pRB->ResGetCount(); i < cnt; i++)
@@ -246,7 +246,7 @@ void CConvertDlg::AddFilter(HTREEITEM hTIParent, IBaseFilter* pBFParent) if(len > 0)
{
- m_pTIs.AddTail(new CTreeItemResource(CDSMResource(name, desc, mime, pData, len), m_tree, *t2));
+ m_pTIs.AddTail(DNew CTreeItemResource(CDSMResource(name, desc, mime, pData, len), m_tree, *t2));
}
CoTaskMemFree(pData);
@@ -254,7 +254,7 @@ void CConvertDlg::AddFilter(HTREEITEM hTIParent, IBaseFilter* pBFParent) }
m_tree.Expand(*t2, TVE_EXPAND);
- CTreeItem* t3 = new CTreeItemChapterFolder(m_tree, hTIParent);
+ CTreeItem* t3 = DNew CTreeItemChapterFolder(m_tree, hTIParent);
if(CComQIPtr<IDSMChapterBag> pCB = pBFParent)
{
for(DWORD i = 0, cnt = pCB->ChapGetCount(); i < cnt; i++)
@@ -264,7 +264,7 @@ void CConvertDlg::AddFilter(HTREEITEM hTIParent, IBaseFilter* pBFParent) if(FAILED(pCB->ChapGet(i, &rt, &name)))
continue;
- m_pTIs.AddTail(new CTreeItemChapter(CDSMChapter(rt, name), m_tree, *t3));
+ m_pTIs.AddTail(DNew CTreeItemChapter(CDSMChapter(rt, name), m_tree, *t3));
}
}
m_tree.Expand(*t3, TVE_EXPAND);
@@ -537,7 +537,7 @@ void CConvertDlg::ShowResourceFolderPopup(HTREEITEM hTI, CPoint p) && ERROR_SUCCESS == key.QueryStringValue(_T("Content Type"), mime, &len))
res.mime = mime;
- CTreeItemResource* t = new CTreeItemResource(res, m_tree, hTI);
+ CTreeItemResource* t = DNew CTreeItemResource(res, m_tree, hTI);
m_pTIs.AddTail(t);
if(EditResource(t))
@@ -698,7 +698,7 @@ void CConvertDlg::ShowChapterFolderPopup(HTREEITEM hTI, CPoint p) case 1:
{
CDSMChapter chap;
- CTreeItemChapter* t = new CTreeItemChapter(CDSMChapter(0, L""), m_tree, hTI);
+ CTreeItemChapter* t = DNew CTreeItemChapter(CDSMChapter(0, L""), m_tree, hTI);
m_pTIs.AddTail(t);
if(!EditChapter(t))
DeleteItem(*t);
@@ -803,9 +803,9 @@ BOOL CConvertDlg::OnInitDialog() m_nIDEventStatus = SetTimer(1, 1000, NULL);
HRESULT hr;
- m_pMux = new CDSMMuxerFilter(NULL, &hr, false, false);
+ m_pMux = DNew CDSMMuxerFilter(NULL, &hr, false, false);
- m_pGB = new CFGManagerMuxer(_T("CFGManagerMuxer"), NULL);
+ m_pGB = DNew CFGManagerMuxer(_T("CFGManagerMuxer"), NULL);
m_pGB->AddToROT();
if(FAILED(m_pGB->AddFilter(m_pMux, L"Mux"))
diff --git a/src/apps/mplayerc/DX7AllocatorPresenter.cpp b/src/apps/mplayerc/DX7AllocatorPresenter.cpp index 9524b44d7..050910564 100644 --- a/src/apps/mplayerc/DX7AllocatorPresenter.cpp +++ b/src/apps/mplayerc/DX7AllocatorPresenter.cpp @@ -193,9 +193,9 @@ HRESULT CreateAP7(const CLSID& clsid, HWND hWnd, ISubPicAllocatorPresenter** ppA *ppAP = NULL;
HRESULT hr;
- if(clsid == CLSID_VMR7AllocatorPresenter && !(*ppAP = new CVMR7AllocatorPresenter(hWnd, hr))
- || clsid == CLSID_RM7AllocatorPresenter && !(*ppAP = new CRM7AllocatorPresenter(hWnd, hr))
- || clsid == CLSID_QT7AllocatorPresenter && !(*ppAP = new CQT7AllocatorPresenter(hWnd, hr)))
+ if(clsid == CLSID_VMR7AllocatorPresenter && !(*ppAP = DNew CVMR7AllocatorPresenter(hWnd, hr))
+ || clsid == CLSID_RM7AllocatorPresenter && !(*ppAP = DNew CRM7AllocatorPresenter(hWnd, hr))
+ || clsid == CLSID_QT7AllocatorPresenter && !(*ppAP = DNew CQT7AllocatorPresenter(hWnd, hr)))
return E_OUTOFMEMORY;
if(*ppAP == NULL)
@@ -289,7 +289,7 @@ static HRESULT TextureBlt(CComPtr<IDirect3DDevice7> pD3DDev, CComPtr<IDirectDraw //
CDX7AllocatorPresenter::CDX7AllocatorPresenter(HWND hWnd, HRESULT& hr)
- : ISubPicAllocatorPresenterImpl(hWnd, hr)
+ : ISubPicAllocatorPresenterImpl(hWnd, hr, NULL)
, m_ScreenSize(0, 0)
{
if(FAILED(hr)) return;
@@ -373,6 +373,10 @@ HRESULT CDX7AllocatorPresenter::CreateDevice() case 3: size.SetSize(640, 480); break;
case 4: size.SetSize(512, 384); break;
case 5: size.SetSize(384, 288); break;
+ case 6: size.SetSize(2560, 1600); break;
+ case 7: size.SetSize(1920, 1080); break;
+ case 8: size.SetSize(1320, 900); break;
+ case 9: size.SetSize(1280, 720); break;
}
if(m_pAllocator)
@@ -381,15 +385,15 @@ HRESULT CDX7AllocatorPresenter::CreateDevice() }
else
{
- m_pAllocator = new CDX7SubPicAllocator(m_pD3DDev, size, AfxGetAppSettings().fSPCPow2Tex);
+ m_pAllocator = DNew CDX7SubPicAllocator(m_pD3DDev, size, AfxGetAppSettings().fSPCPow2Tex);
if(!m_pAllocator || FAILED(hr))
return E_FAIL;
}
hr = S_OK;
m_pSubPicQueue = AfxGetAppSettings().nSPCSize > 0
- ? (ISubPicQueue*)new CSubPicQueue(AfxGetAppSettings().nSPCSize, m_pAllocator, &hr)
- : (ISubPicQueue*)new CSubPicQueueNoThread(m_pAllocator, &hr);
+ ? (ISubPicQueue*)DNew CSubPicQueue(AfxGetAppSettings().nSPCSize, AfxGetAppSettings().fSPCDisableAnim, m_pAllocator, &hr)
+ : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
if(!m_pSubPicQueue || FAILED(hr))
return E_FAIL;
diff --git a/src/apps/mplayerc/DX9AllocatorPresenter.cpp b/src/apps/mplayerc/DX9AllocatorPresenter.cpp index 2eb20a495..f9d21acad 100644 --- a/src/apps/mplayerc/DX9AllocatorPresenter.cpp +++ b/src/apps/mplayerc/DX9AllocatorPresenter.cpp @@ -55,6 +55,20 @@ CCritSec g_ffdshowReceive;
bool queueu_ffdshow_support = false;
+CString GetWindowsErrorMessage(HRESULT _Error, HMODULE _Module)
+{
+ CString errmsg;
+ LPVOID lpMsgBuf;
+ if(FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_HMODULE,
+ _Module, _Error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL))
+ {
+ errmsg = (LPCTSTR)lpMsgBuf;
+ LocalFree(lpMsgBuf);
+ }
+ CString Temp;
+ Temp.Format(L"0x%08x ", _Error);
+ return Temp + errmsg;
+}
bool IsVMR9InGraph(IFilterGraph* pFG)
{
@@ -75,10 +89,11 @@ HRESULT CreateAP9(const CLSID& clsid, HWND hWnd, ISubPicAllocatorPresenter** ppA *ppAP = NULL;
HRESULT hr = E_FAIL;
- if(clsid == CLSID_VMR9AllocatorPresenter && !(*ppAP = new CVMR9AllocatorPresenter(hWnd, hr))
- || clsid == CLSID_RM9AllocatorPresenter && !(*ppAP = new CRM9AllocatorPresenter(hWnd, hr))
- || clsid == CLSID_QT9AllocatorPresenter && !(*ppAP = new CQT9AllocatorPresenter(hWnd, hr))
- || clsid == CLSID_DXRAllocatorPresenter && !(*ppAP = new CDXRAllocatorPresenter(hWnd, hr)))
+ CString Error;
+ if(clsid == CLSID_VMR9AllocatorPresenter && !(*ppAP = DNew CVMR9AllocatorPresenter(hWnd, hr, Error))
+ || clsid == CLSID_RM9AllocatorPresenter && !(*ppAP = DNew CRM9AllocatorPresenter(hWnd, hr, Error))
+ || clsid == CLSID_QT9AllocatorPresenter && !(*ppAP = DNew CQT9AllocatorPresenter(hWnd, hr, Error))
+ || clsid == CLSID_DXRAllocatorPresenter && !(*ppAP = DNew CDXRAllocatorPresenter(hWnd, hr, Error)))
return E_OUTOFMEMORY;
if(*ppAP == NULL)
@@ -88,18 +103,103 @@ HRESULT CreateAP9(const CLSID& clsid, HWND hWnd, ISubPicAllocatorPresenter** ppA if(FAILED(hr))
{
+ Error += L"\n";
+ Error += GetWindowsErrorMessage(hr, NULL);
+
+ MessageBox(hWnd, Error, L"Error creating DX9 allocation presenter", MB_OK|MB_ICONERROR);
(*ppAP)->Release();
*ppAP = NULL;
}
+ else if (!Error.IsEmpty())
+ {
+ MessageBox(hWnd, Error, L"Warning creating DX9 allocation presenter", MB_OK|MB_ICONWARNING);
+ }
return hr;
}
+const wchar_t *GetD3DFormatStr(D3DFORMAT Format)
+{
+ switch (Format)
+ {
+ case D3DFMT_R8G8B8 : return L"R8G8B8";
+ case D3DFMT_A8R8G8B8 : return L"A8R8G8B8";
+ case D3DFMT_X8R8G8B8 : return L"X8R8G8B8";
+ case D3DFMT_R5G6B5 : return L"R5G6B5";
+ case D3DFMT_X1R5G5B5 : return L"X1R5G5B5";
+ case D3DFMT_A1R5G5B5 : return L"A1R5G5B5";
+ case D3DFMT_A4R4G4B4 : return L"A4R4G4B4";
+ case D3DFMT_R3G3B2 : return L"R3G3B2";
+ case D3DFMT_A8 : return L"A8";
+ case D3DFMT_A8R3G3B2 : return L"A8R3G3B2";
+ case D3DFMT_X4R4G4B4 : return L"X4R4G4B4";
+ case D3DFMT_A2B10G10R10: return L"A2B10G10R10";
+ case D3DFMT_A8B8G8R8 : return L"A8B8G8R8";
+ case D3DFMT_X8B8G8R8 : return L"X8B8G8R8";
+ case D3DFMT_G16R16 : return L"G16R16";
+ case D3DFMT_A2R10G10B10: return L"A2R10G10B10";
+ case D3DFMT_A16B16G16R16 : return L"A16B16G16R16";
+ case D3DFMT_A8P8 : return L"A8P8";
+ case D3DFMT_P8 : return L"P8";
+ case D3DFMT_L8 : return L"L8";
+ case D3DFMT_A8L8 : return L"A8L8";
+ case D3DFMT_A4L4 : return L"A4L4";
+ case D3DFMT_V8U8 : return L"V8U8";
+ case D3DFMT_L6V5U5 : return L"L6V5U5";
+ case D3DFMT_X8L8V8U8 : return L"X8L8V8U8";
+ case D3DFMT_Q8W8V8U8 : return L"Q8W8V8U8";
+ case D3DFMT_V16U16 : return L"V16U16";
+ case D3DFMT_A2W10V10U10: return L"A2W10V10U10";
+ case D3DFMT_UYVY : return L"UYVY";
+ case D3DFMT_R8G8_B8G8: return L"R8G8_B8G8";
+ case D3DFMT_YUY2 : return L"YUY2";
+ case D3DFMT_G8R8_G8B8: return L"G8R8_G8B8";
+ case D3DFMT_DXT1 : return L"DXT1";
+ case D3DFMT_DXT2 : return L"DXT2";
+ case D3DFMT_DXT3 : return L"DXT3";
+ case D3DFMT_DXT4 : return L"DXT4";
+ case D3DFMT_DXT5 : return L"DXT5";
+ case D3DFMT_D16_LOCKABLE : return L"D16_LOCKABLE";
+ case D3DFMT_D32: return L"D32";
+ case D3DFMT_D15S1: return L"D15S1";
+ case D3DFMT_D24S8: return L"D24S8";
+ case D3DFMT_D24X8: return L"D24X8";
+ case D3DFMT_D24X4S4: return L"D24X4S4";
+ case D3DFMT_D16: return L"D16";
+ case D3DFMT_D32F_LOCKABLE: return L"D32F_LOCKABLE";
+ case D3DFMT_D24FS8 : return L"D24FS8";
+ case D3DFMT_D32_LOCKABLE : return L"D32_LOCKABLE";
+ case D3DFMT_S8_LOCKABLE: return L"S8_LOCKABLE";
+ case D3DFMT_L16: return L"L16";
+ case D3DFMT_VERTEXDATA : return L"VERTEXDATA";
+ case D3DFMT_INDEX16: return L"INDEX16";
+ case D3DFMT_INDEX32: return L"INDEX32";
+ case D3DFMT_Q16W16V16U16 : return L"Q16W16V16U16";
+ case D3DFMT_MULTI2_ARGB8 : return L"MULTI2_ARGB8";
+ case D3DFMT_R16F : return L"R16F";
+ case D3DFMT_G16R16F: return L"G16R16F";
+ case D3DFMT_A16B16G16R16F: return L"A16B16G16R16F";
+ case D3DFMT_R32F : return L"R32F";
+ case D3DFMT_G32R32F: return L"G32R32F";
+ case D3DFMT_A32B32G32R32F: return L"A32B32G32R32F";
+ case D3DFMT_CxV8U8 : return L"CxV8U8";
+ case D3DFMT_A1 : return L"A1";
+ case D3DFMT_BINARYBUFFER : return L"BINARYBUFFER";
+ }
+ return L"Unknown";
+}
+
//
#pragma pack(push, 1)
template<int texcoords>
struct MYD3DVERTEX {float x, y, z, rhw; struct {float u, v;} t[texcoords];};
+template<>
+struct MYD3DVERTEX<0>
+{
+ float x, y, z, rhw;
+ DWORD Diffuse;
+};
#pragma pack(pop)
template<int texcoords>
@@ -172,17 +272,12 @@ static HRESULT TextureBlt(CComPtr<IDirect3DDevice9> pD3DDev, MYD3DVERTEX<texcoor //
- if(FAILED(hr = pD3DDev->BeginScene()))
- break;
-
hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | FVF);
// hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, v, sizeof(v[0]));
MYD3DVERTEX<texcoords> tmp = v[2]; v[2] = v[3]; v[3] = tmp;
hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
- hr = pD3DDev->EndScene();
-
//
for(int i = 0; i < texcoords; i++)
@@ -197,65 +292,522 @@ static HRESULT TextureBlt(CComPtr<IDirect3DDevice9> pD3DDev, MYD3DVERTEX<texcoor return E_FAIL;
}
+static HRESULT DrawRect(CComPtr<IDirect3DDevice9> pD3DDev, MYD3DVERTEX<0> v[4])
+{
+ if(!pD3DDev)
+ return E_POINTER;
+
+ do
+ {
+ HRESULT hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
+ hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ hr = pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+ hr = pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
+ //D3DRS_COLORVERTEX
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
+
+
+ hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
+
+ hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX0 | D3DFVF_DIFFUSE);
+ // hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, v, sizeof(v[0]));
+
+ MYD3DVERTEX<0> tmp = v[2]; v[2] = v[3]; v[3] = tmp;
+ hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
+
+ return S_OK;
+ }
+ while(0);
+
+ return E_FAIL;
+}
+
// CDX9AllocatorPresenter
-CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, HRESULT& hr)
- : ISubPicAllocatorPresenterImpl(hWnd, hr)
+CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, HRESULT& hr, bool bIsEVR, CString &_Error)
+ : ISubPicAllocatorPresenterImpl(hWnd, hr, &_Error)
, m_ScreenSize(0, 0)
, m_RefreshRate(0)
, m_bicubicA(0)
, m_nTearingPos(0)
, m_nNbDXSurface(1)
+ , m_nVMR9Surfaces(0)
+ , m_iVMR9Surface(0)
, m_nCurSurface(0)
, m_rtTimePerFrame(0)
+ , m_bInterlaced(0)
, m_nUsedBuffer(0)
+ , m_bNeedPendingResetDevice(0)
+ , m_bPendingResetDevice(0)
+ , m_OrderedPaint(0)
+ , m_bCorrectedFrameTime(0)
+ , m_FrameTimeCorrection(0)
+ , m_LastSampleTime(0)
+ , m_LastFrameDuration(0)
+ , m_bAlternativeVSync(0)
+ , m_bIsEVR(bIsEVR)
+ , m_VSyncMode(0)
+ , m_TextScale(1.0)
+
{
+
+ m_pDirectDraw = NULL;
+ m_hVSyncThread = INVALID_HANDLE_VALUE;
+ m_hEvtQuit = INVALID_HANDLE_VALUE;
+
+ m_bIsFullscreen = (AfxGetApp()->m_pMainWnd != NULL) && (((CMainFrame*)AfxGetApp()->m_pMainWnd)->IsD3DFullScreenMode());
+
HINSTANCE hDll;
- if(FAILED(hr)) return;
- m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
- if(!m_pD3D) m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
- if(!m_pD3D) {hr = E_FAIL; return;}
+ if(FAILED(hr))
+ {
+ _Error += L"ISubPicAllocatorPresenterImpl failed\n";
+ return;
+ }
m_pD3DXLoadSurfaceFromMemory = NULL;
m_pD3DXCreateLine = NULL;
m_pD3DXCreateFont = NULL;
+ m_pD3DXCreateSprite = NULL;
hDll = AfxGetMyApp()->GetD3X9Dll();
if(hDll)
{
- m_pD3DXLoadSurfaceFromMemory = (D3DXLoadSurfaceFromMemoryPtr)GetProcAddress(hDll, "D3DXLoadSurfaceFromMemory");
- m_pD3DXCreateLine = (D3DXCreateLinePtr) GetProcAddress(hDll, "D3DXCreateLine");
- m_pD3DXCreateFont = (D3DXCreateFontPtr) GetProcAddress(hDll, "D3DXCreateFontW");
+ (FARPROC&)m_pD3DXLoadSurfaceFromMemory = GetProcAddress(hDll, "D3DXLoadSurfaceFromMemory");
+ (FARPROC&)m_pD3DXCreateLine = GetProcAddress(hDll, "D3DXCreateLine");
+ (FARPROC&)m_pD3DXCreateFont = GetProcAddress(hDll, "D3DXCreateFontW");
+ (FARPROC&)m_pD3DXCreateSprite = GetProcAddress(hDll, "D3DXCreateSprite");
+ }
+ else
+ {
+ _Error += L"No D3DX9 dll found. To enable stats, shaders and complex resizers, please make sure to install the latest DirectX SDK Redistributable.\n";
+ }
+
+ m_pDwmIsCompositionEnabled = NULL;
+ m_pDwmEnableComposition = NULL;
+ m_hDWMAPI = LoadLibrary(L"dwmapi.dll");
+ if (m_hDWMAPI)
+ {
+ (FARPROC &)m_pDwmIsCompositionEnabled = GetProcAddress(m_hDWMAPI, "DwmIsCompositionEnabled");
+ (FARPROC &)m_pDwmEnableComposition = GetProcAddress(m_hDWMAPI, "DwmEnableComposition");
+ }
+
+ m_hD3D9 = LoadLibrary(L"d3d9.dll");
+ if (m_hD3D9)
+ {
+ (FARPROC &)m_pDirect3DCreate9Ex = GetProcAddress(m_hD3D9, "Direct3DCreate9Ex");
}
+ else
+ m_pDirect3DCreate9Ex = NULL;
+ if (m_pDirect3DCreate9Ex)
+ {
+ m_pDirect3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
+ if(!m_pD3DEx)
+ {
+ m_pDirect3DCreate9Ex(D3D9b_SDK_VERSION, &m_pD3DEx);
+ }
+ }
+ if(!m_pD3DEx)
+ {
+ m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
+ if(!m_pD3D)
+ {
+ m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
+ }
+ if(!m_pD3D) {hr = E_FAIL; return;}
+ }
+ else
+ m_pD3D = m_pD3DEx;
+
+
+ m_DetectedFrameRate = 0.0;
+ m_DetectedFrameTime = 0.0;
+ m_DetectedFrameTimeStdDev = 0.0;
+ m_DetectedLock = false;
+ ZeroMemory(m_DetectedFrameTimeHistory, sizeof(m_DetectedFrameTimeHistory));
+ ZeroMemory(m_DetectedFrameTimeHistoryHisotry, sizeof(m_DetectedFrameTimeHistoryHisotry));
+ m_DetectedFrameTimePos = 0;
ZeroMemory(&m_VMR9AlphaBitmap, sizeof(m_VMR9AlphaBitmap));
- hr = CreateDevice();
+
+ ZeroMemory(m_ldDetectedRefreshRateList, sizeof(m_ldDetectedRefreshRateList));
+ ZeroMemory(m_ldDetectedScanlineRateList, sizeof(m_ldDetectedScanlineRateList));
+ m_DetectedRefreshRatePos = 0;
+ m_DetectedRefreshTimePrim = 0;
+ m_DetectedScanlineTime = 0;
+ m_DetectedScanlineTimePrim = 0;
+ m_DetectedRefreshRate = 0;
+ AppSettings& s = AfxGetAppSettings();
+
+ if (s.m_RenderSettings.iVMRDisableDesktopComposition)
+ {
+ m_bDesktopCompositionDisabled = true;
+ if (m_pDwmEnableComposition)
+ m_pDwmEnableComposition(0);
+ }
+ else
+ {
+ m_bDesktopCompositionDisabled = false;
+ }
+
+ hr = CreateDevice(_Error);
memset (m_pllJitter, 0, sizeof(m_pllJitter));
+ memset (m_pllSyncOffset, 0, sizeof(m_pllSyncOffset));
m_nNextJitter = 0;
+ m_nNextSyncOffset = 0;
m_llLastPerf = 0;
m_fAvrFps = 0.0;
+ m_fJitterStdDev = 0.0;
+ m_fSyncOffsetStdDev = 0.0;
+ m_fSyncOffsetAvr = 0.0;
+ m_bSyncStatsAvailable = false;
}
CDX9AllocatorPresenter::~CDX9AllocatorPresenter()
{
+ if (m_bDesktopCompositionDisabled)
+ {
+ m_bDesktopCompositionDisabled = false;
+ if (m_pDwmEnableComposition)
+ m_pDwmEnableComposition(1);
+ }
+
+ StopWorkerThreads();
m_pFont = NULL;
m_pLine = NULL;
m_pD3DDev = NULL;
+ m_pD3DDevEx = NULL;
m_pPSC.Free();
m_pD3D.Detach();
+ m_pD3DEx.Detach();
+ if (m_hDWMAPI)
+ {
+ FreeLibrary(m_hDWMAPI);
+ m_hDWMAPI = NULL;
+ }
+ if (m_hD3D9)
+ {
+ FreeLibrary(m_hD3D9);
+ m_hD3D9 = NULL;
+ }
}
-HRESULT CDX9AllocatorPresenter::CreateDevice()
+void ModerateFloat(double& Value, double Target, double& ValuePrim, double ChangeSpeed);
+
+
+void CDX9AllocatorPresenter::VSyncThread()
{
+ HANDLE hAvrt;
+ HANDLE hEvts[] = { m_hEvtQuit};
+ bool bQuit = false;
+ TIMECAPS tc;
+ DWORD dwResolution;
+ DWORD dwUser = 0;
+ DWORD dwTaskIndex = 0;
+
+ // Tell Vista Multimedia Class Scheduler we are a playback thretad (increase priority)
+// if (pfAvSetMmThreadCharacteristicsW)
+// hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
+// if (pfAvSetMmThreadPriority)
+// pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/);
+ Sleep(2000);
+
+ timeGetDevCaps(&tc, sizeof(TIMECAPS));
+ dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
+ dwUser = timeBeginPeriod(dwResolution);
+ CMPlayerCApp *pApp = (CMPlayerCApp*)AfxGetApp();
+ AppSettings& s = AfxGetAppSettings();
+
+ while (!bQuit)
+ {
+
+ DWORD dwObject = WaitForMultipleObjects (countof(hEvts), hEvts, FALSE, 1);
+ switch (dwObject)
+ {
+ case WAIT_OBJECT_0 :
+ bQuit = true;
+ break;
+ case WAIT_TIMEOUT :
+ {
+ // Do our stuff
+ if (m_pD3DDev && s.m_RenderSettings.iVMR9VSync)
+ {
+
+ int VSyncPos = GetVBlackPos();
+ int WaitRange = max(m_ScreenSize.cy / 40, 5);
+ int MinRange = max(min(int(0.003 * double(m_ScreenSize.cy) * double(m_RefreshRate) + 0.5), m_ScreenSize.cy/3), 5); // 1.8 ms or max 33 % of Time
+
+ VSyncPos += MinRange + WaitRange;
+
+ VSyncPos = VSyncPos % m_ScreenSize.cy;
+ if (VSyncPos < 0)
+ VSyncPos += m_ScreenSize.cy;
+
+ int ScanLine = 0;
+ int bInVBlank = 0;
+ int StartScanLine = ScanLine;
+ int LastPos = ScanLine;
+ ScanLine = (VSyncPos + 1) % m_ScreenSize.cy;
+ if (ScanLine < 0)
+ ScanLine += m_ScreenSize.cy;
+ int FirstScanLine = ScanLine;
+ int ScanLineMiddle = ScanLine + m_ScreenSize.cy/2;
+ ScanLineMiddle = ScanLineMiddle % m_ScreenSize.cy;
+ if (ScanLineMiddle < 0)
+ ScanLineMiddle += m_ScreenSize.cy;
+
+ int ScanlineStart = ScanLine;
+ WaitForVBlankRange(ScanlineStart, 5, true, true, false);
+ LONGLONG TimeStart = pApp->GetPerfCounter();
+
+ WaitForVBlankRange(ScanLineMiddle, 5, true, true, false);
+ LONGLONG TimeMiddle = pApp->GetPerfCounter();
+
+ int ScanlineEnd = ScanLine;
+ WaitForVBlankRange(ScanlineEnd, 5, true, true, false);
+ LONGLONG TimeEnd = pApp->GetPerfCounter();
+
+ double nSeconds = double(TimeEnd - TimeStart) / 10000000.0;
+ LONGLONG DiffMiddle = TimeMiddle - TimeStart;
+ LONGLONG DiffEnd = TimeEnd - TimeMiddle;
+ double DiffDiff;
+ if (DiffEnd > DiffMiddle)
+ DiffDiff = double(DiffEnd) / double(DiffMiddle);
+ else
+ DiffDiff = double(DiffMiddle) / double(DiffEnd);
+ if (nSeconds > 0.003 && DiffDiff < 1.3)
+ {
+ double ScanLineSeconds;
+ double nScanLines;
+ if (ScanLineMiddle > ScanlineEnd)
+ {
+ ScanLineSeconds = double(TimeMiddle - TimeStart) / 10000000.0;
+ nScanLines = ScanLineMiddle - ScanlineStart;
+ }
+ else
+ {
+ ScanLineSeconds = double(TimeEnd - TimeMiddle) / 10000000.0;
+ nScanLines = ScanlineEnd - ScanLineMiddle;
+ }
+
+ double ScanLineTime = ScanLineSeconds / nScanLines;
+
+ int iPos = m_DetectedRefreshRatePos % 100;
+ m_ldDetectedScanlineRateList[iPos] = ScanLineTime;
+ if (m_DetectedScanlineTime && ScanlineStart != ScanlineEnd)
+ {
+ int Diff = ScanlineEnd - ScanlineStart;
+ nSeconds -= double(Diff) * m_DetectedScanlineTime;
+ }
+ m_ldDetectedRefreshRateList[iPos] = nSeconds;
+ double Average = 0;
+ double AverageScanline = 0;
+ int nPos = min(iPos + 1, 100);
+ for (int i = 0; i < nPos; ++i)
+ {
+ Average += m_ldDetectedRefreshRateList[i];
+ AverageScanline += m_ldDetectedScanlineRateList[i];
+ }
+
+ Average /= double(nPos);
+ AverageScanline /= double(nPos);
+
+ double ThisValue = Average;
+
+ {
+ CAutoLock Lock(&m_RefreshRateLock);
+ ++m_DetectedRefreshRatePos;
+ if (m_DetectedRefreshTime == 0 || m_DetectedRefreshTime / ThisValue > 1.01 || m_DetectedRefreshTime / ThisValue < 0.99)
+ {
+ m_DetectedRefreshTime = ThisValue;
+ m_DetectedRefreshTimePrim = 0;
+ }
+ ModerateFloat(m_DetectedRefreshTime, ThisValue, m_DetectedRefreshTimePrim, 1.5);
+ m_DetectedRefreshRate = 1.0/m_DetectedRefreshTime;
+
+ if (m_DetectedScanlineTime == 0 || m_DetectedScanlineTime / AverageScanline > 1.01 || m_DetectedScanlineTime / AverageScanline < 0.99)
+ {
+ m_DetectedScanlineTime = AverageScanline;
+ m_DetectedScanlineTimePrim = 0;
+ }
+ ModerateFloat(m_DetectedScanlineTime, AverageScanline, m_DetectedScanlineTimePrim, 1.5);
+ m_DetectedScanlinesPerFrame = m_DetectedRefreshTime / m_DetectedScanlineTime;
+ }
+ //TRACE("Refresh: %f\n", RefreshRate);
+ }
+ }
+ else
+ {
+ m_DetectedRefreshRate = 0.0;
+ m_DetectedScanlinesPerFrame = 0.0;
+ }
+ }
+ break;
+ }
+ }
+
+ timeEndPeriod (dwResolution);
+// if (pfAvRevertMmThreadCharacteristics) pfAvRevertMmThreadCharacteristics (hAvrt);
+}
+
+
+DWORD WINAPI CDX9AllocatorPresenter::VSyncThreadStatic(LPVOID lpParam)
+{
+ CDX9AllocatorPresenter* pThis = (CDX9AllocatorPresenter*) lpParam;
+ pThis->VSyncThread();
+ return 0;
+}
+
+void CDX9AllocatorPresenter::StartWorkerThreads()
+{
+ DWORD dwThreadId;
+
+ m_hEvtQuit = CreateEvent (NULL, TRUE, FALSE, NULL);
+ if (m_bIsEVR)
+ {
+ m_hVSyncThread = ::CreateThread(NULL, 0, VSyncThreadStatic, (LPVOID)this, 0, &dwThreadId);
+ SetThreadPriority(m_hVSyncThread, THREAD_PRIORITY_HIGHEST);
+ }
+}
+
+void CDX9AllocatorPresenter::StopWorkerThreads()
+{
+ SetEvent (m_hEvtQuit);
+ if ((m_hVSyncThread != INVALID_HANDLE_VALUE) && (WaitForSingleObject (m_hVSyncThread, 10000) == WAIT_TIMEOUT))
+ {
+ ASSERT (FALSE);
+ TerminateThread (m_hVSyncThread, 0xDEAD);
+ }
+
+ if (m_hVSyncThread != INVALID_HANDLE_VALUE) CloseHandle (m_hVSyncThread);
+ if (m_hEvtQuit != INVALID_HANDLE_VALUE) CloseHandle (m_hEvtQuit);
+ m_hVSyncThread = INVALID_HANDLE_VALUE;
+ m_hEvtQuit = INVALID_HANDLE_VALUE;
+
+}
+
+bool CDX9AllocatorPresenter::SettingsNeedResetDevice()
+{
+ AppSettings& s = AfxGetAppSettings();
+ CMPlayerCApp::Settings::CRendererSettingsEVR & New = AfxGetAppSettings().m_RenderSettings;
+ CMPlayerCApp::Settings::CRendererSettingsEVR & Current = m_LastRendererSettings;
+
+ bool bRet = false;
+
+ bRet = bRet || New.fVMR9AlterativeVSync != Current.fVMR9AlterativeVSync;
+ bRet = bRet || New.iVMR9VSyncAccurate != Current.iVMR9VSyncAccurate;
+
+ if (m_bIsFullscreen)
+ {
+ bRet = bRet || New.iVMR9FullscreenGUISupport != Current.iVMR9FullscreenGUISupport;
+ }
+ else
+ {
+ if (Current.iVMRDisableDesktopComposition)
+ {
+ if (!m_bDesktopCompositionDisabled)
+ {
+ m_bDesktopCompositionDisabled = true;
+ if (m_pDwmEnableComposition)
+ m_pDwmEnableComposition(0);
+ }
+ }
+ else
+ {
+ if (m_bDesktopCompositionDisabled)
+ {
+ m_bDesktopCompositionDisabled = false;
+ if (m_pDwmEnableComposition)
+ m_pDwmEnableComposition(1);
+ }
+ }
+ }
+
+ if (m_bIsEVR)
+ {
+ bRet = bRet || New.iEVRHighColorResolution != Current.iEVRHighColorResolution;
+ }
+
+ m_LastRendererSettings = s.m_RenderSettings;
+
+ return bRet;
+}
+
+HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error)
+{
+ StopWorkerThreads();
+ AppSettings& s = AfxGetAppSettings();
+ m_VBlankEndWait = 0;
+ m_VBlankMin = 300000;
+ m_VBlankMinCalc = 300000;
+ m_VBlankMax = 0;
+ m_VBlankStartWait = 0;
+ m_VBlankWaitTime = 0;
+ m_PresentWaitTime = 0;
+ m_PresentWaitTimeMin = 3000000000;
+ m_PresentWaitTimeMax = 0;
+
+ m_LastRendererSettings = s.m_RenderSettings;
+
+ m_VBlankEndPresent = -100000;
+ m_VBlankStartMeasureTime = 0;
+ m_VBlankStartMeasure = 0;
+
+ m_PaintTime = 0;
+ m_PaintTimeMin = 3000000000;
+ m_PaintTimeMax = 0;
+
+ m_RasterStatusWaitTime = 0;
+ m_RasterStatusWaitTimeMin = 3000000000;
+ m_RasterStatusWaitTimeMax = 0;
+ m_RasterStatusWaitTimeMaxCalc = 0;
+
+ m_ClockDiff = 0.0;
+ m_ClockDiffPrim = 0.0;
+ m_ClockDiffCalc = 0.0;
+
+ m_ModeratedTimeSpeed = 1.0;
+ m_ModeratedTimeSpeedDiff = 0.0;
+ m_ModeratedTimeSpeedPrim = 0;
+ ZeroMemory(m_TimeChangeHisotry, sizeof(m_TimeChangeHisotry));
+ ZeroMemory(m_ClockChangeHisotry, sizeof(m_ClockChangeHisotry));
+ m_ClockTimeChangeHistoryPos = 0;
+
m_pPSC.Free();
m_pD3DDev = NULL;
+ m_pD3DDevEx = NULL;
+ m_pDirectDraw = NULL;
+
+ m_pResizerPixelShader[0] = 0;
+ m_pResizerPixelShader[1] = 0;
+ m_pResizerPixelShader[2] = 0;
+
+ POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
+ while(pos)
+ {
+ CExternalPixelShader &Shader = m_pPixelShadersScreenSpace.GetNext(pos);
+ Shader.m_pPixelShader = NULL;
+ }
+ pos = m_pPixelShaders.GetHeadPosition();
+ while(pos)
+ {
+ CExternalPixelShader &Shader = m_pPixelShaders.GetNext(pos);
+ Shader.m_pPixelShader = NULL;
+ }
+
D3DDISPLAYMODE d3ddm;
HRESULT hr;
ZeroMemory(&d3ddm, sizeof(d3ddm));
if(FAILED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm)))
+ {
+ _Error += L"GetAdapterDisplayMode failed\n";
return E_UNEXPECTED;
+ }
/* // TODO : add nVidia PerfHUD !!!
@@ -292,29 +844,102 @@ if (FAILED(g_pD3D->CreateDevice( AdapterToUse, DeviceType, hWnd, */
+//#define ENABLE_DDRAWSYNC
+#ifdef ENABLE_DDRAWSYNC
+ hr = DirectDrawCreate(NULL, &m_pDirectDraw, NULL) ;
+ if (hr == S_OK)
+ {
+ hr = m_pDirectDraw->SetCooperativeLevel(m_hWnd, DDSCL_NORMAL) ;
+ }
+#endif
+
m_RefreshRate = d3ddm.RefreshRate;
m_ScreenSize.SetSize(d3ddm.Width, d3ddm.Height);
D3DPRESENT_PARAMETERS pp;
ZeroMemory(&pp, sizeof(pp));
-
- if (AfxGetAppSettings().IsD3DFullscreen())
+ BOOL bCompositionEnabled = false;
+ if (m_pDwmIsCompositionEnabled)
+ m_pDwmIsCompositionEnabled(&bCompositionEnabled);
+
+ m_bCompositionEnabled = bCompositionEnabled != 0;
+
+ m_bAlternativeVSync = s.m_RenderSettings.fVMR9AlterativeVSync;
+ m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution && m_bIsEVR;
+
+ if (m_bIsFullscreen)
{
pp.Windowed = false;
pp.BackBufferWidth = d3ddm.Width;
pp.BackBufferHeight = d3ddm.Height;
pp.hDeviceWindow = m_hWnd;
- pp.BackBufferCount = 1;
- pp.SwapEffect = D3DSWAPEFFECT_FLIP; // Ne pas mettre D3DSWAPEFFECT_COPY car cela entraine une desynchro audio sur les MKV !
+ if(m_bAlternativeVSync)
+ {
+ pp.BackBufferCount = 3;
+ pp.SwapEffect = D3DSWAPEFFECT_DISCARD; // Ne pas mettre D3DSWAPEFFECT_COPY car cela entraine une desynchro audio sur les MKV ! // Copy needed for sync now? FLIP only stutters.
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
+ }
+ else
+ {
+ pp.BackBufferCount = 3;
+ pp.SwapEffect = D3DSWAPEFFECT_DISCARD; // Ne pas mettre D3DSWAPEFFECT_COPY car cela entraine une desynchro audio sur les MKV ! // Copy needed for sync now? FLIP only stutters.
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
+ }
pp.Flags = D3DPRESENTFLAG_VIDEO;
- pp.BackBufferFormat = d3ddm.Format;
- pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
+ if (s.m_RenderSettings.iVMR9FullscreenGUISupport && !m_bHighColorResolution)
+ pp.Flags |= D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
+ if (m_bHighColorResolution)
+ pp.BackBufferFormat = D3DFMT_A2R10G10B10;
+ else
+ pp.BackBufferFormat = d3ddm.Format;
+
+ m_D3DDevExError = L"No m_pD3DEx";
+ if (m_pD3DEx)
+ {
+ D3DDISPLAYMODEEX DisplayMode;
+ ZeroMemory(&DisplayMode, sizeof(DisplayMode));
+ DisplayMode.Size = sizeof(DisplayMode);
+ m_pD3DEx->GetAdapterDisplayModeEx(GetAdapter(m_pD3DEx), &DisplayMode, NULL);
- hr = m_pD3D->CreateDevice(
- GetAdapter(m_pD3D), D3DDEVTYPE_HAL, m_hWnd,
- D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
- &pp, &m_pD3DDev);
+ DisplayMode.Format = pp.BackBufferFormat;
+ pp.FullScreen_RefreshRateInHz = DisplayMode.RefreshRate;
+
+ hr = m_pD3DEx->CreateDeviceEx(
+ GetAdapter(m_pD3D), D3DDEVTYPE_HAL, m_hWnd,
+ D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
+ &pp, &DisplayMode, &m_pD3DDevEx);
+
+ m_D3DDevExError = GetWindowsErrorMessage(hr, m_hD3D9);
+ if (m_pD3DDevEx)
+ {
+ m_pD3DDev = m_pD3DDevEx;
+ m_BackbufferType = pp.BackBufferFormat;
+ m_DisplayType = DisplayMode.Format;
+ }
+ }
+
+ if (!m_pD3DDev)
+ {
+ hr = m_pD3D->CreateDevice(
+ GetAdapter(m_pD3D), D3DDEVTYPE_HAL, m_hWnd,
+ D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
+ &pp, &m_pD3DDev);
+ if (m_pD3DDev)
+ {
+ m_BackbufferType = pp.BackBufferFormat;
+ m_DisplayType = d3ddm.Format;
+ }
+ }
+ if (m_pD3DDev && s.m_RenderSettings.iVMR9FullscreenGUISupport && !m_bHighColorResolution)
+ {
+ m_pD3DDev->SetDialogBoxMode(true);
+ //if (m_pD3DDev->SetDialogBoxMode(true) != S_OK)
+ // ExitProcess(0);
+
+ }
+
+ TRACE("CreateDevice: %d\n", (LONG)hr);
ASSERT (SUCCEEDED (hr));
}
else
@@ -323,28 +948,60 @@ if (FAILED(g_pD3D->CreateDevice( AdapterToUse, DeviceType, hWnd, pp.hDeviceWindow = m_hWnd;
pp.SwapEffect = D3DSWAPEFFECT_COPY;
pp.Flags = D3DPRESENTFLAG_VIDEO;
+ pp.BackBufferCount = 1;
pp.BackBufferWidth = d3ddm.Width;
pp.BackBufferHeight = d3ddm.Height;
- pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
+ m_BackbufferType = d3ddm.Format;
+ m_DisplayType = d3ddm.Format;
+ if (m_bHighColorResolution)
+ {
+ m_BackbufferType = D3DFMT_A2R10G10B10;
+ pp.BackBufferFormat = D3DFMT_A2R10G10B10;
+ }
+ if (bCompositionEnabled || m_bAlternativeVSync)
+ {
+ // Desktop composition takes care of the VSYNC
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
+ }
+ else
+ {
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
+ }
- if(m_fVMRSyncFix = AfxGetMyApp()->m_s.fVMRSyncFix)
- pp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
+// if(m_fVMRSyncFix = AfxGetMyApp()->m_s.fVMRSyncFix)
+// pp.Flags |= D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
- hr = m_pD3D->CreateDevice(
+ if (m_pD3DEx)
+ {
+ hr = m_pD3DEx->CreateDeviceEx(
+ GetAdapter(m_pD3D), D3DDEVTYPE_HAL, m_hWnd,
+ D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
+ &pp, NULL, &m_pD3DDevEx);
+ if (m_pD3DDevEx)
+ m_pD3DDev = m_pD3DDevEx;
+ }
+ else
+ {
+ hr = m_pD3D->CreateDevice(
GetAdapter(m_pD3D), D3DDEVTYPE_HAL, m_hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
&pp, &m_pD3DDev);
+ }
}
-/*
- HRESULT hr = m_pD3D->CreateDevice(
- m_pD3D->GetAdapterCount()-1, D3DDEVTYPE_REF, m_hWnd,
- D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
- &pp, &m_pD3DDev);
-*/
+
+ if (m_pD3DDevEx)
+ {
+ m_pD3DDevEx->SetGPUThreadPriority(7);
+ }
+
if(FAILED(hr))
+ {
+ _Error += L"CreateDevice failed\n";
+
return hr;
+ }
- m_pPSC.Attach(new CPixelShaderCompiler(m_pD3DDev, true));
+ m_pPSC.Attach(DNew CPixelShaderCompiler(m_pD3DDev, true));
//
@@ -375,6 +1032,10 @@ if (FAILED(g_pD3D->CreateDevice( AdapterToUse, DeviceType, hWnd, case 3: size.SetSize(640, 480); break;
case 4: size.SetSize(512, 384); break;
case 5: size.SetSize(384, 288); break;
+ case 6: size.SetSize(2560, 1600); break;
+ case 7: size.SetSize(1920, 1080); break;
+ case 8: size.SetSize(1320, 900); break;
+ case 9: size.SetSize(1280, 720); break;
}
if(m_pAllocator)
@@ -383,45 +1044,71 @@ if (FAILED(g_pD3D->CreateDevice( AdapterToUse, DeviceType, hWnd, }
else
{
- m_pAllocator = new CDX9SubPicAllocator(m_pD3DDev, size, AfxGetAppSettings().fSPCPow2Tex);
+ m_pAllocator = DNew CDX9SubPicAllocator(m_pD3DDev, size, AfxGetAppSettings().fSPCPow2Tex);
if(!m_pAllocator)
+ {
+ _Error += L"CDX9SubPicAllocator failed\n";
+
return E_FAIL;
+ }
}
hr = S_OK;
m_pSubPicQueue = AfxGetAppSettings().nSPCSize > 0
- ? (ISubPicQueue*)new CSubPicQueue(AfxGetAppSettings().nSPCSize, m_pAllocator, &hr)
- : (ISubPicQueue*)new CSubPicQueueNoThread(m_pAllocator, &hr);
+ ? (ISubPicQueue*)DNew CSubPicQueue(AfxGetAppSettings().nSPCSize, AfxGetAppSettings().fSPCDisableAnim, m_pAllocator, &hr)
+ : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
if(!m_pSubPicQueue || FAILED(hr))
+ {
+ _Error += L"m_pSubPicQueue failed\n";
+
return E_FAIL;
+ }
if(pSubPicProvider) m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
m_pFont = NULL;
if (m_pD3DXCreateFont)
+ {
+ int MinSize = 1600;
+ int CurrentSize = min(m_ScreenSize.cx, MinSize);
+ double Scale = double(CurrentSize) / double(MinSize);
+ m_TextScale = Scale;
m_pD3DXCreateFont( m_pD3DDev, // D3D device
- -20, // Height
- 0, // Width
- FW_BOLD, // Weight
- 1, // MipLevels, 0 = autogen mipmaps
+ -24.0*Scale, // Height
+ -11.0*Scale, // Width
+ CurrentSize < 800 ? FW_NORMAL : FW_BOLD, // Weight
+ 0, // MipLevels, 0 = autogen mipmaps
FALSE, // Italic
DEFAULT_CHARSET, // CharSet
OUT_DEFAULT_PRECIS, // OutputPrecision
- DEFAULT_QUALITY, // Quality
- DEFAULT_PITCH | FF_DONTCARE, // PitchAndFamily
- L"Courrier", // pFaceName
+ ANTIALIASED_QUALITY, // Quality
+ FIXED_PITCH | FF_DONTCARE, // PitchAndFamily
+ L"Lucida Console", // pFaceName
&m_pFont); // ppFont
+ }
+
+
+ m_pSprite = NULL;
+
+ if (m_pD3DXCreateSprite)
+ {
+ m_pD3DXCreateSprite( m_pD3DDev, // D3D device
+ &m_pSprite);
+ }
m_pLine = NULL;
if (m_pD3DXCreateLine)
m_pD3DXCreateLine (m_pD3DDev, &m_pLine);
+ StartWorkerThreads();
+
return S_OK;
}
HRESULT CDX9AllocatorPresenter::AllocSurfaces(D3DFORMAT Format)
{
CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
AppSettings& s = AfxGetAppSettings();
@@ -431,7 +1118,10 @@ HRESULT CDX9AllocatorPresenter::AllocSurfaces(D3DFORMAT Format) m_pVideoSurface[i] = NULL;
}
- m_pResizerBicubic1stPass = NULL;
+ m_pScreenSizeTemporaryTexture[0] = NULL;
+ m_pScreenSizeTemporaryTexture[1] = NULL;
+
+ m_SurfaceType = Format;
HRESULT hr;
@@ -476,6 +1166,7 @@ HRESULT CDX9AllocatorPresenter::AllocSurfaces(D3DFORMAT Format) void CDX9AllocatorPresenter::DeleteSurfaces()
{
CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
for(int i = 0; i < m_nNbDXSurface+2; i++)
{
@@ -535,16 +1226,49 @@ static bool ClipToSurface(IDirect3DSurface9* pSurface, CRect& s, CRect& d) return(true);
}
-HRESULT CDX9AllocatorPresenter::InitResizers(float bicubicA)
+HRESULT CDX9AllocatorPresenter::InitResizers(float bicubicA, bool bNeedScreenSizeTexture)
{
HRESULT hr;
- if(m_pResizerPixelShader[0] && m_bicubicA == 0 && bicubicA == 0
- || m_pResizerPixelShader[1] && m_pResizerPixelShader[2] && m_bicubicA == bicubicA && m_pResizerBicubic1stPass)
+ do
+ {
+ if (bicubicA)
+ {
+ if (!m_pResizerPixelShader[0])
+ break;
+ if (!m_pResizerPixelShader[1])
+ break;
+ if (!m_pResizerPixelShader[2])
+ break;
+ if (m_bicubicA != bicubicA)
+ break;
+ if (!m_pScreenSizeTemporaryTexture[0])
+ break;
+ if (bNeedScreenSizeTexture)
+ {
+ if (!m_pScreenSizeTemporaryTexture[1])
+ break;
+ }
+ }
+ else
+ {
+ if (!m_pResizerPixelShader[0])
+ break;
+ if (bNeedScreenSizeTexture)
+ {
+ if (!m_pScreenSizeTemporaryTexture[0])
+ break;
+ if (!m_pScreenSizeTemporaryTexture[1])
+ break;
+ }
+ }
return S_OK;
+ }
+ while (0);
m_bicubicA = bicubicA;
- m_pResizerBicubic1stPass = NULL;
+ m_pScreenSizeTemporaryTexture[0] = NULL;
+ m_pScreenSizeTemporaryTexture[1] = NULL;
for(int i = 0; i < countof(m_pResizerPixelShader); i++)
m_pResizerPixelShader[i] = NULL;
@@ -573,14 +1297,24 @@ HRESULT CDX9AllocatorPresenter::InitResizers(float bicubicA) if(FAILED(hr)) return hr;
}
- if(m_bicubicA)
+ if(m_bicubicA || bNeedScreenSizeTexture)
+ {
+ if(FAILED(m_pD3DDev->CreateTexture(
+ min(m_ScreenSize.cx, (int)m_caps.MaxTextureWidth), min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_caps.MaxTextureHeight), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
+ D3DPOOL_DEFAULT, &m_pScreenSizeTemporaryTexture[0], NULL)))
+ {
+ ASSERT(0);
+ m_pScreenSizeTemporaryTexture[0] = NULL; // will do 1 pass then
+ }
+ }
+ if(m_bicubicA || bNeedScreenSizeTexture)
{
if(FAILED(m_pD3DDev->CreateTexture(
- min(max(2048, m_ScreenSize.cx), (int)m_caps.MaxTextureWidth), m_NativeVideoSize.cy, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
- D3DPOOL_DEFAULT, &m_pResizerBicubic1stPass, NULL)))
+ min(m_ScreenSize.cx, (int)m_caps.MaxTextureWidth), min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_caps.MaxTextureHeight), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
+ D3DPOOL_DEFAULT, &m_pScreenSizeTemporaryTexture[1], NULL)))
{
ASSERT(0);
- m_pResizerBicubic1stPass = NULL; // will do 1 pass then
+ m_pScreenSizeTemporaryTexture[1] = NULL; // will do 1 pass then
}
}
@@ -617,6 +1351,26 @@ HRESULT CDX9AllocatorPresenter::TextureCopy(CComPtr<IDirect3DTexture9> pTexture) return TextureBlt(m_pD3DDev, v, D3DTEXF_LINEAR);
}
+HRESULT CDX9AllocatorPresenter::DrawRect(DWORD _Color, DWORD _Alpha, const CRect &_Rect)
+{
+ DWORD Color = D3DCOLOR_ARGB(_Alpha, GetRValue(_Color), GetGValue(_Color), GetBValue(_Color));
+ MYD3DVERTEX<0> v[] =
+ {
+ {float(_Rect.left), float(_Rect.top), 0.5f, 2.0f, Color},
+ {float(_Rect.right), float(_Rect.top), 0.5f, 2.0f, Color},
+ {float(_Rect.left), float(_Rect.bottom), 0.5f, 2.0f, Color},
+ {float(_Rect.right), float(_Rect.bottom), 0.5f, 2.0f, Color},
+ };
+
+ for(int i = 0; i < countof(v); i++)
+ {
+ v[i].x -= 0.5;
+ v[i].y -= 0.5;
+ }
+
+ return ::DrawRect(m_pD3DDev, v);
+}
+
HRESULT CDX9AllocatorPresenter::TextureResize(CComPtr<IDirect3DTexture9> pTexture, Vector dst[4], D3DTEXTUREFILTERTYPE filter)
{
HRESULT hr;
@@ -750,7 +1504,7 @@ HRESULT CDX9AllocatorPresenter::TextureResizeBicubic2pass(CComPtr<IDirect3DTextu CRect dst1(0, 0, (int)(dst[3].x - dst[0].x), (int)h);
- if(!m_pResizerBicubic1stPass || FAILED(m_pResizerBicubic1stPass->GetLevelDesc(0, &desc)))
+ if(!m_pScreenSizeTemporaryTexture[0] || FAILED(m_pScreenSizeTemporaryTexture[0]->GetLevelDesc(0, &desc)))
return TextureResizeBicubic1pass(pTexture, dst);
float dy = 0.98f/desc.Height;
@@ -758,7 +1512,7 @@ HRESULT CDX9AllocatorPresenter::TextureResizeBicubic2pass(CComPtr<IDirect3DTextu float dw = (float)dst1.Width() / desc.Width;
float dh = (float)dst1.Height() / desc.Height;
- ASSERT(dst1.Height() == desc.Height);
+// ASSERT(dst1.Height() == desc.Height);
if(dst1.Width() > (int)desc.Width || dst1.Height() > (int)desc.Height)
// if(dst1.Width() != desc.Width || dst1.Height() != desc.Height)
@@ -795,15 +1549,15 @@ HRESULT CDX9AllocatorPresenter::TextureResizeBicubic2pass(CComPtr<IDirect3DTextu hr = m_pD3DDev->GetRenderTarget(0, &pRTOld);
CComPtr<IDirect3DSurface9> pRT;
- hr = m_pResizerBicubic1stPass->GetSurfaceLevel(0, &pRT);
+ hr = m_pScreenSizeTemporaryTexture[0]->GetSurfaceLevel(0, &pRT);
hr = m_pD3DDev->SetRenderTarget(0, pRT);
hr = TextureBlt(m_pD3DDev, vx, D3DTEXF_POINT);
- hr = m_pD3DDev->SetTexture(0, m_pResizerBicubic1stPass);
- hr = m_pD3DDev->SetTexture(1, m_pResizerBicubic1stPass);
- hr = m_pD3DDev->SetTexture(2, m_pResizerBicubic1stPass);
- hr = m_pD3DDev->SetTexture(3, m_pResizerBicubic1stPass);
+ hr = m_pD3DDev->SetTexture(0, m_pScreenSizeTemporaryTexture[0]);
+ hr = m_pD3DDev->SetTexture(1, m_pScreenSizeTemporaryTexture[0]);
+ hr = m_pD3DDev->SetTexture(2, m_pScreenSizeTemporaryTexture[0]);
+ hr = m_pD3DDev->SetTexture(3, m_pScreenSizeTemporaryTexture[0]);
hr = m_pD3DDev->SetRenderTarget(0, pRTOld);
@@ -893,14 +1647,9 @@ HRESULT CDX9AllocatorPresenter::AlphaBlt(RECT* pSrc, RECT* pDst, CComPtr<IDirect hr = m_pD3DDev->SetPixelShader(NULL);
- if(FAILED(hr = m_pD3DDev->BeginScene()))
- break;
-
hr = m_pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
hr = m_pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pVertices, sizeof(pVertices[0]));
- hr = m_pD3DDev->EndScene();
-
//
m_pD3DDev->SetTexture(0, NULL);
@@ -916,17 +1665,357 @@ HRESULT CDX9AllocatorPresenter::AlphaBlt(RECT* pSrc, RECT* pDst, CComPtr<IDirect return E_FAIL;
}
+void CDX9AllocatorPresenter::CalculateJitter(LONGLONG PerfCounter)
+{
+ // Calculate the jitter!
+ LONGLONG llPerf = PerfCounter;
+ if ((m_rtTimePerFrame != 0) && (labs ((long)(llPerf - m_llLastPerf)) < m_rtTimePerFrame*3) )
+ {
+ m_nNextJitter = (m_nNextJitter+1) % NB_JITTER;
+ m_pllJitter[m_nNextJitter] = llPerf - m_llLastPerf;
+
+ m_MaxJitter = MINLONG64;
+ m_MinJitter = MAXLONG64;
+
+ // Calculate the real FPS
+ LONGLONG llJitterSum = 0;
+ LONGLONG llJitterSumAvg = 0;
+ for (int i=0; i<NB_JITTER; i++)
+ {
+ LONGLONG Jitter = m_pllJitter[i];
+ llJitterSum += Jitter;
+ llJitterSumAvg += Jitter;
+ }
+ double FrameTimeMean = double(llJitterSumAvg)/NB_JITTER;
+ m_fJitterMean = FrameTimeMean;
+ double DeviationSum = 0;
+ for (int i=0; i<NB_JITTER; i++)
+ {
+ LONGLONG DevInt = m_pllJitter[i] - FrameTimeMean;
+ double Deviation = DevInt;
+ DeviationSum += Deviation*Deviation;
+ m_MaxJitter = max(m_MaxJitter, DevInt);
+ m_MinJitter = min(m_MinJitter, DevInt);
+ }
+ double StdDev = sqrt(DeviationSum/NB_JITTER);
+
+ m_fJitterStdDev = StdDev;
+
+ m_fAvrFps = 10000000.0/(double(llJitterSum)/NB_JITTER);
+ }
+
+ m_llLastPerf = llPerf;
+}
+
+bool CDX9AllocatorPresenter::GetVBlank(int &_ScanLine, int &_bInVBlank, bool _bMeasureTime)
+{
+ LONGLONG llPerf;
+ if (_bMeasureTime)
+ llPerf = AfxGetMyApp()->GetPerfCounter();
+
+ int ScanLine = 0;
+ _ScanLine = 0;
+ _bInVBlank = 0;
+ if (m_pDirectDraw)
+ {
+ DWORD ScanLineGet = 0;
+ m_pDirectDraw->GetScanLine(&ScanLineGet);
+ BOOL InVBlank;
+ if (m_pDirectDraw->GetVerticalBlankStatus (&InVBlank) != S_OK)
+ return false;
+ ScanLine = ScanLineGet;
+ _bInVBlank = InVBlank;
+ if (InVBlank)
+ ScanLine = 0;
+ }
+ else
+ {
+ D3DRASTER_STATUS RasterStatus;
+ if (m_pD3DDev->GetRasterStatus(0, &RasterStatus) != S_OK)
+ return false;;
+ ScanLine = RasterStatus.ScanLine;
+ _bInVBlank = RasterStatus.InVBlank;
+ }
+ if (_bMeasureTime)
+ {
+ m_VBlankMax = max(m_VBlankMax, ScanLine);
+ if (ScanLine != 0 && !_bInVBlank)
+ m_VBlankMinCalc = min(m_VBlankMinCalc, ScanLine);
+ m_VBlankMin = m_VBlankMax - m_ScreenSize.cy;
+ }
+ if (_bInVBlank)
+ _ScanLine = 0;
+ else if (m_VBlankMin != 300000)
+ _ScanLine = ScanLine - m_VBlankMin;
+ else
+ _ScanLine = ScanLine;
+
+ if (_bMeasureTime)
+ {
+ LONGLONG Time = AfxGetMyApp()->GetPerfCounter() - llPerf;
+ m_RasterStatusWaitTimeMaxCalc = max(m_RasterStatusWaitTimeMaxCalc, Time);
+ }
+
+ return true;
+}
+
+bool CDX9AllocatorPresenter::WaitForVBlankRange(int &_RasterStart, int _RasterSize, bool _bWaitIfInside, bool _bNeedAccurate, bool _bMeasure)
+{
+ if (_bMeasure)
+ m_RasterStatusWaitTimeMaxCalc = 0;
+ bool bWaited = false;
+ int ScanLine = 0;
+ int InVBlank = 0;
+ LONGLONG llPerf;
+ if (_bMeasure)
+ llPerf = AfxGetMyApp()->GetPerfCounter();
+ GetVBlank(ScanLine, InVBlank, _bMeasure);
+ if (_bMeasure)
+ m_VBlankStartWait = ScanLine;
+
+ static bool bOneWait = true;
+ if (bOneWait && _bMeasure)
+ {
+ bOneWait = false;
+ // If we are already in the wanted interval we need to wait until we aren't, this improves sync when for example you are playing 23.976 Hz material on a 24 Hz refresh rate
+ int nInVBlank = 0;
+ while (1)
+ {
+ if (!GetVBlank(ScanLine, InVBlank, _bMeasure))
+ break;
+
+ if (InVBlank && nInVBlank == 0)
+ {
+ nInVBlank = 1;
+ }
+ else if (!InVBlank && nInVBlank == 1)
+ {
+ nInVBlank = 2;
+ }
+ else if (InVBlank && nInVBlank == 2)
+ {
+ nInVBlank = 3;
+ }
+ else if (!InVBlank && nInVBlank == 3)
+ {
+ break;
+ }
+ }
+ }
+ if (_bWaitIfInside)
+ {
+ int ScanLineDiff = long(ScanLine) - _RasterStart;
+ if (ScanLineDiff > m_ScreenSize.cy / 2)
+ ScanLineDiff -= m_ScreenSize.cy;
+ else if (ScanLineDiff < -m_ScreenSize.cy / 2)
+ ScanLineDiff += m_ScreenSize.cy;
+
+ if (ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize)
+ {
+ bWaited = true;
+ // If we are already in the wanted interval we need to wait until we aren't, this improves sync when for example you are playing 23.976 Hz material on a 24 Hz refresh rate
+ int LastLineDiff = ScanLineDiff;
+ while (1)
+ {
+ if (!GetVBlank(ScanLine, InVBlank, _bMeasure))
+ break;
+ int ScanLineDiff = long(ScanLine) - _RasterStart;
+ if (ScanLineDiff > m_ScreenSize.cy / 2)
+ ScanLineDiff -= m_ScreenSize.cy;
+ else if (ScanLineDiff < -m_ScreenSize.cy / 2)
+ ScanLineDiff += m_ScreenSize.cy;
+ if (!(ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize) || (LastLineDiff < 0 && ScanLineDiff > 0))
+ break;
+ LastLineDiff = ScanLineDiff;
+ Sleep(1); // Just sleep
+ }
+ }
+ }
+ int MinRange = max(min(int(0.0015 * double(m_ScreenSize.cy) * double(m_RefreshRate) + 0.5), m_ScreenSize.cy/3), 5); // 1.5 ms or max 33 % of Time
+ int NoSleepStart = _RasterStart - MinRange;
+ int NoSleepRange = MinRange;
+ if (NoSleepStart < 0)
+ NoSleepStart += m_ScreenSize.cy;
+
+ int ScanLineDiff = ScanLine - _RasterStart;
+ if (ScanLineDiff > m_ScreenSize.cy / 2)
+ ScanLineDiff -= m_ScreenSize.cy;
+ else if (ScanLineDiff < -m_ScreenSize.cy / 2)
+ ScanLineDiff += m_ScreenSize.cy;
+ int LastLineDiff = ScanLineDiff;
+ int LastLineDiffSleep = long(ScanLine) - NoSleepStart;
+ while (1)
+ {
+ if (!GetVBlank(ScanLine, InVBlank, _bMeasure))
+ break;
+ int ScanLineDiff = long(ScanLine) - _RasterStart;
+ if (ScanLineDiff > m_ScreenSize.cy / 2)
+ ScanLineDiff -= m_ScreenSize.cy;
+ else if (ScanLineDiff < -m_ScreenSize.cy / 2)
+ ScanLineDiff += m_ScreenSize.cy;
+ if ((ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize) || (LastLineDiff < 0 && ScanLineDiff > 0))
+ break;
+
+ LastLineDiff = ScanLineDiff;
+
+ bWaited = true;
+
+ int ScanLineDiffSleep = long(ScanLine) - NoSleepStart;
+ if (ScanLineDiffSleep > m_ScreenSize.cy / 2)
+ ScanLineDiffSleep -= m_ScreenSize.cy;
+ else if (ScanLineDiffSleep < -m_ScreenSize.cy / 2)
+ ScanLineDiffSleep += m_ScreenSize.cy;
+
+ if (!((ScanLineDiffSleep >= 0 && ScanLineDiffSleep <= NoSleepRange) || (LastLineDiffSleep < 0 && ScanLineDiffSleep > 0)) || !_bNeedAccurate)
+ {
+ //TRACE("%d\n", RasterStatus.ScanLine);
+ Sleep(1); // Don't sleep for the last 1.5 ms scan lines, so we get maximum precision
+ }
+ LastLineDiffSleep = ScanLineDiffSleep;
+ }
+ _RasterStart = ScanLine;
+ if (_bMeasure)
+ {
+ m_VBlankEndWait = ScanLine;
+ m_VBlankWaitTime = AfxGetMyApp()->GetPerfCounter() - llPerf;
+
+ m_RasterStatusWaitTime = m_RasterStatusWaitTimeMaxCalc;
+ m_RasterStatusWaitTimeMin = min(m_RasterStatusWaitTimeMin, m_RasterStatusWaitTime);
+ m_RasterStatusWaitTimeMax = max(m_RasterStatusWaitTimeMax, m_RasterStatusWaitTime);
+ }
+
+ return bWaited;
+}
+
+int CDX9AllocatorPresenter::GetVBlackPos()
+{
+ AppSettings& s = AfxGetAppSettings();
+ BOOL bCompositionEnabled = m_bCompositionEnabled;
+
+ int WaitRange = max(m_ScreenSize.cy / 40, 5);
+ if (!bCompositionEnabled)
+ {
+ if (m_bAlternativeVSync)
+ {
+ return s.m_RenderSettings.iVMR9VSyncOffset;
+ }
+ else
+ {
+ int MinRange = max(min(int(0.005 * double(m_ScreenSize.cy) * GetRefreshRate() + 0.5), m_ScreenSize.cy/3), 5); // 5 ms or max 33 % of Time
+ int WaitFor = m_ScreenSize.cy - (MinRange + WaitRange);
+ return WaitFor;
+ }
+ }
+ else
+ {
+ int WaitFor = m_ScreenSize.cy / 2;
+ return WaitFor;
+ }
+}
+
+
+bool CDX9AllocatorPresenter::WaitForVBlank(bool &_Waited)
+{
+ AppSettings& s = AfxGetAppSettings();
+ if (!s.m_RenderSettings.iVMR9VSync)
+ {
+ _Waited = true;
+ m_VBlankWaitTime = 0;
+ m_VBlankEndWait = 0;
+ m_VBlankStartWait = 0;
+ return true;
+ }
+// _Waited = true;
+// return false;
+
+ BOOL bCompositionEnabled = m_bCompositionEnabled;
+ int WaitFor = GetVBlackPos();
+
+ if (!bCompositionEnabled)
+ {
+ if (m_bAlternativeVSync)
+ {
+ _Waited = WaitForVBlankRange(WaitFor, 0, false, true, true);
+ return false;
+ }
+ else
+ {
+ _Waited = WaitForVBlankRange(WaitFor, 0, false, s.m_RenderSettings.iVMR9VSyncAccurate, true);
+ return true;
+ }
+ }
+ else
+ {
+ // Instead we wait for VBlack after the present, this seems to fix the stuttering problem. It's also possible to fix by removing the Sleep above, but that isn't an option.
+ WaitForVBlankRange(WaitFor, 0, false, s.m_RenderSettings.iVMR9VSyncAccurate, true);
+
+ return false;
+ }
+}
+
+void CDX9AllocatorPresenter::UpdateAlphaBitmap()
+{
+ m_VMR9AlphaBitmapData.Free();
+
+ if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0)
+ {
+ HBITMAP hBitmap = (HBITMAP)GetCurrentObject (m_VMR9AlphaBitmap.hdc, OBJ_BITMAP);
+ if (!hBitmap)
+ return;
+ DIBSECTION info = {0};
+ if (!::GetObject(hBitmap, sizeof( DIBSECTION ), &info ))
+ return;
+
+ m_VMR9AlphaBitmapRect = CRect(0, 0, info.dsBm.bmWidth, info.dsBm.bmHeight);
+ m_VMR9AlphaBitmapWidthBytes = info.dsBm.bmWidthBytes;
+
+ if (m_VMR9AlphaBitmapData.Allocate(info.dsBm.bmWidthBytes * info.dsBm.bmHeight))
+ {
+ memcpy((BYTE *)m_VMR9AlphaBitmapData, info.dsBm.bmBits, info.dsBm.bmWidthBytes * info.dsBm.bmHeight);
+ }
+ }
+}
STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll)
{
+// if (!fAll)
+// return false;
AppSettings& s = AfxGetAppSettings();
- CAutoLock cAutoLock(this);
+// TRACE("Thread: %d\n", (LONG)((CRITICAL_SECTION &)m_RenderLock).OwningThread);
+
+#if 0
+ if (TryEnterCriticalSection (&(CRITICAL_SECTION &)(*((CCritSec *)this))))
+ {
+ LeaveCriticalSection((&(CRITICAL_SECTION &)(*((CCritSec *)this))));
+ }
+ else
+ {
+ __asm {
+ int 3
+ };
+ }
+#endif
+
+ CMPlayerCApp * pApp = AfxGetMyApp();
+
+ LONGLONG StartPaint = pApp->GetPerfCounter();
+ CAutoLock cRenderLock(&m_RenderLock);
if(m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
|| m_NativeVideoSize.cx <= 0 || m_NativeVideoSize.cy <= 0
|| !m_pVideoSurface)
+ {
+ if (m_OrderedPaint)
+ --m_OrderedPaint;
+ else
+ {
+ TRACE("UNORDERED PAINT!!!!!!\n");
+ }
+
+
return(false);
+ }
HRESULT hr;
@@ -936,12 +2025,14 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll) CRect rSrcPri(CPoint(0, 0), m_WindowRect.Size());
CRect rDstPri(m_WindowRect);
+ m_pD3DDev->BeginScene();
+
CComPtr<IDirect3DSurface9> pBackBuffer;
m_pD3DDev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
m_pD3DDev->SetRenderTarget(0, pBackBuffer);
- if(fAll)
+// if(fAll)
{
// clear the backbuffer
@@ -984,7 +2075,10 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll) pVideoTexture = m_pVideoTexture[dst];
hr = m_pD3DDev->SetRenderTarget(0, m_pVideoSurface[dst]);
- hr = m_pD3DDev->SetPixelShader(m_pPixelShaders.GetNext(pos));
+ CExternalPixelShader &Shader = m_pPixelShaders.GetNext(pos);
+ if (!Shader.m_pPixelShader)
+ Shader.Compile(m_pPSC);
+ hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
TextureCopy(m_pVideoTexture[src]);
//if(++src > 2) src = 1;
@@ -1010,8 +2104,27 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll) case 4: A = -0.751f; break; // FIXME : 0.75 crash recent D3D, or eat CPU
case 5: A = -1.00f; break;
}
+ bool bScreenSpacePixelShaders = !m_pPixelShadersScreenSpace.IsEmpty();
- hr = InitResizers(A);
+ hr = InitResizers(A, bScreenSpacePixelShaders);
+
+ if (!m_pScreenSizeTemporaryTexture[0] || !m_pScreenSizeTemporaryTexture[1])
+ bScreenSpacePixelShaders = false;
+
+ if (bScreenSpacePixelShaders)
+ {
+ CComPtr<IDirect3DSurface9> pRT;
+ hr = m_pScreenSizeTemporaryTexture[1]->GetSurfaceLevel(0, &pRT);
+ if (hr != S_OK)
+ bScreenSpacePixelShaders = false;
+ if (bScreenSpacePixelShaders)
+ {
+ hr = m_pD3DDev->SetRenderTarget(0, pRT);
+ if (hr != S_OK)
+ bScreenSpacePixelShaders = false;
+ hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
+ }
+ }
if(iDX9Resizer == 0 || iDX9Resizer == 1 || rSrcVid.Size() == rDstVid.Size() || FAILED(hr))
{
@@ -1026,6 +2139,62 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll) hr = TextureResizeBicubic2pass(pVideoTexture, dst);
}
+ if (bScreenSpacePixelShaders)
+ {
+ static __int64 counter = 555;
+ static long start = clock() + 333;
+
+ long stop = clock() + 333;
+ long diff = stop - start;
+
+ if(diff >= 10*60*CLOCKS_PER_SEC) start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
+
+ D3DSURFACE_DESC desc;
+ m_pScreenSizeTemporaryTexture[0]->GetLevelDesc(0, &desc);
+
+#if 1
+ float fConstData[][4] =
+ {
+ {(float)desc.Width, (float)desc.Height, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
+ {1.0f / desc.Width, 1.0f / desc.Height, 0, 0},
+ };
+#else
+ float fConstData[][4] =
+ {
+ {(float)m_ScreenSize.cx, (float)m_ScreenSize.cy, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
+ {1.0f / m_ScreenSize.cx, 1.0f / m_ScreenSize.cy, 0, 0},
+ };
+#endif
+
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
+
+ int src = 1, dst = 0;
+
+ POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
+ while(pos)
+ {
+ if (m_pPixelShadersScreenSpace.GetTailPosition() == pos)
+ {
+ m_pD3DDev->SetRenderTarget(0, pBackBuffer);
+ }
+ else
+ {
+ CComPtr<IDirect3DSurface9> pRT;
+ hr = m_pScreenSizeTemporaryTexture[dst]->GetSurfaceLevel(0, &pRT);
+ m_pD3DDev->SetRenderTarget(0, pRT);
+ }
+
+ CExternalPixelShader &Shader = m_pPixelShadersScreenSpace.GetNext(pos);
+ if (!Shader.m_pPixelShader)
+ Shader.Compile(m_pPSC);
+ hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
+ TextureCopy(m_pScreenSizeTemporaryTexture[src]);
+
+ swap(src, dst);
+ }
+
+ hr = m_pD3DDev->SetPixelShader(NULL);
+ }
}
else
{
@@ -1040,7 +2209,17 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll) // Support ffdshow queueing
// m_pD3DDev->StretchRect may fail if ffdshow is using queue output samples.
// Here we don't want to show the black buffer.
- if(FAILED(hr)) return false;
+ if(FAILED(hr))
+ {
+ if (m_OrderedPaint)
+ --m_OrderedPaint;
+ else
+ {
+ TRACE("UNORDERED PAINT!!!!!!\n");
+ }
+
+ return false;
+ }
}
}
}
@@ -1050,13 +2229,15 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll) AlphaBltSubPic(rSrcPri.Size());
}
+
// Casimir666 : affichage de l'OSD
if (m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_UPDATE)
{
+ CAutoLock BitMapLock(&m_VMR9AlphaBitmapLock);
CRect rcSrc (m_VMR9AlphaBitmap.rSrc);
m_pOSDTexture = NULL;
m_pOSDSurface = NULL;
- if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0)
+ if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0 && (BYTE *)m_VMR9AlphaBitmapData)
{
if( (m_pD3DXLoadSurfaceFromMemory != NULL) &&
SUCCEEDED(hr = m_pD3DDev->CreateTexture(rcSrc.Width(), rcSrc.Height(), 1,
@@ -1065,20 +2246,14 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll) {
if (SUCCEEDED (hr = m_pOSDTexture->GetSurfaceLevel(0, &m_pOSDSurface)))
{
- HBITMAP hBitmap = (HBITMAP)GetCurrentObject (m_VMR9AlphaBitmap.hdc, OBJ_BITMAP);
- DIBSECTION info = {0};
-
- ::GetObject(hBitmap, sizeof( DIBSECTION ), &info );
- CRect rcBitmap (0, 0, info.dsBm.bmWidth, info.dsBm.bmHeight);
-
hr = m_pD3DXLoadSurfaceFromMemory (m_pOSDSurface,
NULL,
NULL,
- info.dsBm.bmBits,
+ (BYTE *)m_VMR9AlphaBitmapData,
D3DFMT_A8R8G8B8,
- info.dsBm.bmWidthBytes,
+ m_VMR9AlphaBitmapWidthBytes,
NULL,
- &rcBitmap,
+ &m_VMR9AlphaBitmapRect,
D3DX_FILTER_NONE,
m_VMR9AlphaBitmap.clrSrcKey);
}
@@ -1093,37 +2268,167 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll) }
- if (AfxGetMyApp()->m_fDisplayStats) DrawStats();
+ if (pApp->m_fDisplayStats)
+ DrawStats();
if (m_pOSDTexture) AlphaBlt(rSrcPri, rDstPri, m_pOSDTexture);
- if(m_fVMRSyncFix)
+ m_pD3DDev->EndScene();
+
+ BOOL bCompositionEnabled = m_bCompositionEnabled;
+
+ bool bDoVSyncInPresent = (!bCompositionEnabled && !m_bAlternativeVSync) || !s.m_RenderSettings.iVMR9VSync;
+
+ LONGLONG PresentWaitTime = 0;
+/* if(fAll && m_fVMRSyncFix && bDoVSyncInPresent)
{
+ LONGLONG llPerf = pApp->GetPerfCounter();
D3DLOCKED_RECT lr;
if(SUCCEEDED(pBackBuffer->LockRect(&lr, NULL, 0)))
pBackBuffer->UnlockRect();
- }
+ PresentWaitTime = pApp->GetPerfCounter() - llPerf;
+ }*/
- if ((AfxGetApp()->m_pMainWnd != NULL) && (((CMainFrame*)AfxGetApp()->m_pMainWnd)->IsD3DFullScreenMode()) )
- hr = m_pD3DDev->Present(NULL, NULL, NULL, NULL);
- else
- hr = m_pD3DDev->Present(rSrcPri, rDstPri, NULL, NULL);
+ CComPtr<IDirect3DQuery9> pEventQuery;
- // Calculate the jitter!
- LONGLONG llPerf = AfxGetMyApp()->GetPerfCounter();
- if ((m_rtTimePerFrame != 0) && (labs ((long)(llPerf - m_llLastPerf)) < m_rtTimePerFrame*3) )
+ m_pD3DDev->CreateQuery(D3DQUERYTYPE_EVENT, &pEventQuery);
+ if (pEventQuery)
+ pEventQuery->Issue(D3DISSUE_END);
+
+ if (s.m_RenderSettings.iVMRFlushGPUBeforeVSync && pEventQuery)
{
- m_nNextJitter = (m_nNextJitter+1) % NB_JITTER;
- m_pllJitter[m_nNextJitter] = llPerf - m_llLastPerf - m_rtTimePerFrame;
+ LONGLONG llPerf = pApp->GetPerfCounter();
+ BOOL Data;
+ //Sleep(5);
+ while(S_FALSE == pEventQuery->GetData( &Data, sizeof(Data), D3DGETDATA_FLUSH ))
+ {
+ if (!s.m_RenderSettings.iVMRFlushGPUWait)
+ break;
+ Sleep(1);
+ }
+ if (s.m_RenderSettings.iVMRFlushGPUWait)
+ m_WaitForGPUTime = pApp->GetPerfCounter() - llPerf;
+ else
+ m_WaitForGPUTime = 0;
+ }
+ else
+ m_WaitForGPUTime = 0;
+ if (fAll)
+ {
+ m_PaintTime = (AfxGetMyApp()->GetPerfCounter() - StartPaint);
+ m_PaintTimeMin = min(m_PaintTimeMin, m_PaintTime);
+ m_PaintTimeMax = max(m_PaintTimeMax, m_PaintTime);
+
+ }
- // Calculate the real FPS
- LONGLONG llJitterSum = 0;
- for (int i=0; i<NB_JITTER; i++)
- llJitterSum += m_pllJitter[i];
- m_fAvrFps = 10000000.0/(llJitterSum/125 + m_rtTimePerFrame);
+ bool bWaited = false;
+ if (fAll)
+ {
+ // Only sync to refresh when redrawing all
+ bool bTest = WaitForVBlank(bWaited);
+ ASSERT(bTest == bDoVSyncInPresent);
+ if (!bDoVSyncInPresent)
+ {
+ LONGLONG Time = pApp->GetPerfCounter();
+ OnVBlankFinished(fAll, Time);
+ if (!m_bIsEVR || m_OrderedPaint)
+ CalculateJitter(Time);
+ }
}
- m_llLastPerf = llPerf;
+ // Create a device pointer m_pd3dDevice
+
+ // Create a query object
+
+
+ {
+ CComPtr<IDirect3DQuery9> pEventQuery;
+ m_pD3DDev->CreateQuery(D3DQUERYTYPE_EVENT, &pEventQuery);
+
+ LONGLONG llPerf = pApp->GetPerfCounter();
+ if (m_pD3DDevEx)
+ {
+ if (m_bIsFullscreen)
+ hr = m_pD3DDevEx->PresentEx(NULL, NULL, NULL, NULL, NULL);
+ else
+ hr = m_pD3DDevEx->PresentEx(rSrcPri, rDstPri, NULL, NULL, NULL);
+ }
+ else
+ {
+ if (m_bIsFullscreen)
+ hr = m_pD3DDev->Present(NULL, NULL, NULL, NULL);
+ else
+ hr = m_pD3DDev->Present(rSrcPri, rDstPri, NULL, NULL);
+ }
+ // Issue an End event
+ if (pEventQuery)
+ pEventQuery->Issue(D3DISSUE_END);
+
+ BOOL Data;
+
+ if (s.m_RenderSettings.iVMRFlushGPUAfterPresent && pEventQuery)
+ {
+ LONGLONG FlushStartTime = pApp->GetPerfCounter();
+ while (S_FALSE == pEventQuery->GetData( &Data, sizeof(Data), D3DGETDATA_FLUSH ))
+ {
+ if (!s.m_RenderSettings.iVMRFlushGPUWait)
+ break;
+ if (pApp->GetPerfCounter() - FlushStartTime > 10000)
+ break; // timeout after 10 ms
+ }
+ }
+
+ int ScanLine;
+ int bInVBlank;
+ GetVBlank(ScanLine, bInVBlank, false);
+
+ if (fAll && (!m_bIsEVR || m_OrderedPaint))
+ {
+ m_VBlankEndPresent = ScanLine;
+ }
+
+ while (ScanLine == 0 || bInVBlank)
+ {
+ GetVBlank(ScanLine, bInVBlank, false);
+
+ }
+ m_VBlankStartMeasureTime = pApp->GetPerfCounter();
+ m_VBlankStartMeasure = ScanLine;
+
+ if (fAll && bDoVSyncInPresent)
+ {
+ m_PresentWaitTime = (pApp->GetPerfCounter() - llPerf) + PresentWaitTime;
+ m_PresentWaitTimeMin = min(m_PresentWaitTimeMin, m_PresentWaitTime);
+ m_PresentWaitTimeMax = max(m_PresentWaitTimeMax, m_PresentWaitTime);
+ }
+ else
+ {
+ m_PresentWaitTime = 0;
+ m_PresentWaitTimeMin = min(m_PresentWaitTimeMin, m_PresentWaitTime);
+ m_PresentWaitTimeMax = max(m_PresentWaitTimeMax, m_PresentWaitTime);
+ }
+ }
+
+ if (bDoVSyncInPresent)
+ {
+ LONGLONG Time = pApp->GetPerfCounter();
+ if (!m_bIsEVR || m_OrderedPaint)
+ CalculateJitter(Time);
+ OnVBlankFinished(fAll, Time);
+ }
+
+/* if (!bWaited)
+ {
+ bWaited = true;
+ WaitForVBlank(bWaited);
+ TRACE("Double VBlank\n");
+ ASSERT(bWaited);
+ if (!bDoVSyncInPresent)
+ {
+ CalculateJitter();
+ OnVBlankFinished(fAll);
+ }
+ }*/
bool fResetDevice = false;
if(hr == D3DERR_DEVICELOST && m_pD3DDev->TestCooperativeLevel() == D3DERR_DEVICENOTRESET)
@@ -1131,102 +2436,420 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll) fResetDevice = true;
}
+ if (SettingsNeedResetDevice())
+ fResetDevice = true;
+
+ bCompositionEnabled = false;
+ if (m_pDwmIsCompositionEnabled)
+ m_pDwmIsCompositionEnabled(&bCompositionEnabled);
+ if ((bCompositionEnabled != 0) != m_bCompositionEnabled)
+ {
+ if (m_bIsFullscreen)
+ {
+ m_bCompositionEnabled = (bCompositionEnabled != 0);
+ }
+ else
+ fResetDevice = true;
+ }
+
+
D3DDEVICE_CREATION_PARAMETERS Parameters;
- if(SUCCEEDED(m_pD3DDev->GetCreationParameters(&Parameters))
- && m_pD3D->GetAdapterMonitor(Parameters.AdapterOrdinal) != m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D)))
+ if(SUCCEEDED(m_pD3DDev->GetCreationParameters(&Parameters)) && m_pD3D->GetAdapterMonitor(Parameters.AdapterOrdinal) != m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D)))
{
fResetDevice = true;
}
if(fResetDevice)
{
- DeleteSurfaces();
- if(FAILED(hr = CreateDevice()) || FAILED(hr = AllocSurfaces()))
- return false;
- OnResetDevice();
+ if (m_bNeedPendingResetDevice)
+ {
+ m_bPendingResetDevice = true;
+ }
+ else
+ {
+ ResetDevice();
+ }
}
+ if (m_OrderedPaint)
+ --m_OrderedPaint;
+ else
+ {
+ TRACE("UNORDERED PAINT!!!!!!\n");
+ }
return(true);
}
+double CDX9AllocatorPresenter::GetFrameTime()
+{
+ if (m_DetectedLock)
+ return m_DetectedFrameTime;
+
+ return m_rtTimePerFrame / 10000000.0;
+}
+
+double CDX9AllocatorPresenter::GetFrameRate()
+{
+ if (m_DetectedLock)
+ return m_DetectedFrameRate;
+
+ return 10000000.0 / m_rtTimePerFrame;
+}
+
+bool CDX9AllocatorPresenter::ResetDevice()
+{
+ StopWorkerThreads();
+ DeleteSurfaces();
+ HRESULT hr;
+ CString Error;
+ // TODO: Report error messages here
+ if(FAILED(hr = CreateDevice(Error)) || FAILED(hr = AllocSurfaces()))
+ {
+ return false;
+ }
+ OnResetDevice();
+ return true;
+}
+
+void CDX9AllocatorPresenter::DrawText(const RECT &rc, const CString &strText, int _Priority)
+{
+ if (_Priority < 1)
+ return;
+ int Quality = 1;
+ D3DXCOLOR Color1( 1.0f, 0.2f, 0.2f, 1.0f );
+ D3DXCOLOR Color0( 0.0f, 0.0f, 0.0f, 1.0f );
+ RECT Rect1 = rc;
+ RECT Rect2 = rc;
+ if (Quality == 1)
+ OffsetRect (&Rect2 , 2, 2);
+ else
+ OffsetRect (&Rect2 , -1, -1);
+ if (Quality > 0)
+ m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , 1, 0);
+ if (Quality > 3)
+ m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , 1, 0);
+ if (Quality > 2)
+ m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , 0, 1);
+ if (Quality > 3)
+ m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , 0, 1);
+ if (Quality > 1)
+ m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , -1, 0);
+ if (Quality > 3)
+ m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , -1, 0);
+ if (Quality > 2)
+ m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ OffsetRect (&Rect2 , 0, -1);
+ if (Quality > 3)
+ m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ m_pFont->DrawText( m_pSprite, strText, -1, &Rect1, DT_NOCLIP, Color1);
+}
+
void CDX9AllocatorPresenter::DrawStats()
{
- if (m_pLine && m_pFont)
+ AppSettings& s = AfxGetAppSettings();
+ CMPlayerCApp * pApp = AfxGetMyApp();
+ int bDetailedStats = 2;
+ switch (pApp->m_fDisplayStats)
{
- D3DXVECTOR2 Points[NB_JITTER];
- int nIndex;
+ case 1: bDetailedStats = 2; break;
+ case 2: bDetailedStats = 1; break;
+ case 3: bDetailedStats = 0; break;
+ }
+
+ LONGLONG llMaxJitter = m_MaxJitter;
+ LONGLONG llMinJitter = m_MinJitter;
+ LONGLONG llMaxSyncOffset = m_MaxSyncOffset;
+ LONGLONG llMinSyncOffset = m_MinSyncOffset;
+ if (m_pFont && m_pSprite)
+ {
+ m_pSprite->Begin(D3DXSPRITE_ALPHABLEND);
RECT rc = {700, 40, 0, 0 };
- LONGLONG llMaxJitter = MINLONG64;
- LONGLONG llMinJitter = MAXLONG64;
+ rc.left = 40;
+ CString strText;
+ int TextHeight = 25.0*m_TextScale + 0.5;
+// strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s) (%7.3f ms = %.03f%s) Clock: %7.3f ms %+1.4f %% %+1.9f %+1.9f", m_fAvrFps, double(m_rtTimePerFrame) / 10000.0, 10000000.0 / (double)(m_rtTimePerFrame), m_bInterlaced ? L"I" : L"P", GetFrameTime() * 1000.0, GetFrameRate(), m_DetectedLock ? L" L" : L"", m_ClockDiff/10000.0, m_ModeratedTimeSpeed*100.0 - 100.0, m_ModeratedTimeSpeedDiff, m_ClockDiffCalc/10000.0);
+ if (bDetailedStats > 1)
+ {
+ if (m_bIsEVR)
+ strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s) (%7.3f ms = %.03f%s, %2.03f StdDev) Clock: %1.4f %%", m_fAvrFps, double(m_rtTimePerFrame) / 10000.0, 10000000.0 / (double)(m_rtTimePerFrame), m_bInterlaced ? L"I" : L"P", GetFrameTime() * 1000.0, GetFrameRate(), m_DetectedLock ? L" L" : L"", m_DetectedFrameTimeStdDev / 10000.0, m_ModeratedTimeSpeed*100.0);
+ else
+ strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s)", m_fAvrFps, double(m_rtTimePerFrame) / 10000.0, 10000000.0 / (double)(m_rtTimePerFrame), m_bInterlaced ? L"I" : L"P");
+ }
+// strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s) (%7.3f ms = %.03f%s, %2.03f StdDev)", m_fAvrFps, double(m_rtTimePerFrame) / 10000.0, 10000000.0 / (double)(m_rtTimePerFrame), m_bInterlaced ? L"I" : L"P", GetFrameTime() * 1000.0, GetFrameRate(), m_DetectedLock ? L" L" : L"", m_DetectedFrameTimeStdDev / 10000.0);
+ else
+ strText.Format(L"Frame rate : %7.03f (%.03f%s)", m_fAvrFps, GetFrameRate(), m_DetectedLock ? L" L" : L"");
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
- // === Jitter Graduation
- m_pLine->SetWidth(1.0); // Width
- for (int i=10; i<500; i+= 20)
+ if (bDetailedStats > 1)
{
- Points[0].x = (FLOAT)0;
- Points[0].y = (FLOAT)i;
- Points[1].x = (FLOAT)((i-10)%80 ? 50 : 625);
- Points[1].y = (FLOAT)i;
- if (i == 250) Points[1].x += 50;
- m_pLine->SetWidth(i == 250 ? 2.0F : 1.0F); // Width
- m_pLine->Begin();
- m_pLine->Draw (Points, 2, D3DCOLOR_XRGB(0,0,255));
- m_pLine->End();
+ strText.Format(L"Settings : ");
+
+ if (m_bIsEVR)
+ strText += "EVR ";
+ else
+ strText += "VMR9 ";
+
+ if (s.fD3DFullscreen)
+ strText += "FS ";
+ if (s.m_RenderSettings.iVMR9FullscreenGUISupport)
+ strText += "FSGui ";
+
+ if (s.m_RenderSettings.iVMRDisableDesktopComposition)
+ strText += "DisDC ";
+
+ if (s.m_RenderSettings.iVMRFlushGPUBeforeVSync)
+ strText += "GPUFlushBV ";
+ if (s.m_RenderSettings.iVMRFlushGPUAfterPresent)
+ strText += "GPUFlushAP ";
+
+ if (s.m_RenderSettings.iVMRFlushGPUWait)
+ strText += "GPUFlushWt ";
+
+ if (s.m_RenderSettings.iVMR9VSync)
+ strText += "VS ";
+ if (s.m_RenderSettings.fVMR9AlterativeVSync)
+ strText += "AltVS ";
+ if (s.m_RenderSettings.iVMR9VSyncAccurate)
+ strText += "AccVS ";
+ if (s.m_RenderSettings.iVMR9VSyncOffset)
+ strText.AppendFormat(L"VSOfst(%d)", s.m_RenderSettings.iVMR9VSyncOffset);
+
+ if (m_bIsEVR)
+ {
+ if (s.m_RenderSettings.iEVRHighColorResolution)
+ strText += "10bit ";
+ if (s.m_RenderSettings.iEVREnableFrameTimeCorrection)
+ strText += "FTC ";
+ if (s.m_RenderSettings.iEVROutputRange == 0)
+ strText += "0-255 ";
+ else if (s.m_RenderSettings.iEVROutputRange == 1)
+ strText += "16-235 ";
+ }
+
+
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+
}
- // === Jitter curve
- if (m_rtTimePerFrame)
+ if (bDetailedStats > 1)
{
- for (int i=0; i<NB_JITTER; i++)
+ strText.Format(L"Formats : Surface %s Backbuffer %s Display %s Device %s D3DExError: %s", GetD3DFormatStr(m_SurfaceType), GetD3DFormatStr(m_BackbufferType), GetD3DFormatStr(m_DisplayType), m_pD3DDevEx ? L"D3DDevEx" : L"D3DDev", m_D3DDevExError.GetString());
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+
+ if (m_bIsEVR)
{
- nIndex = (m_nNextJitter+i) % NB_JITTER;
- Points[i].x = (FLOAT)(i*5+5);
- Points[i].y = (FLOAT)(m_pllJitter[nIndex]/5000 + 250);
- llMaxJitter = max(llMaxJitter, m_pllJitter[nIndex]);
- llMinJitter = min(llMinJitter, m_pllJitter[nIndex]);
- }
- m_pLine->Begin();
- m_pLine->Draw (Points, NB_JITTER, D3DCOLOR_XRGB(255,0,0));
- m_pLine->End();
+ strText.Format(L"Refresh rate : %.05f Hz SL: %4d (%3d Hz) Last Duration: %10.6f Corrected Frame Time: %s", m_DetectedRefreshRate, int(m_DetectedScanlinesPerFrame + 0.5), m_RefreshRate, double(m_LastFrameDuration)/10000.0, m_bCorrectedFrameTime?L"Yes":L"No");
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+ }
}
- // === Text
- CString strText;
+ if (m_bSyncStatsAvailable)
+ {
+ if (bDetailedStats > 1)
+ strText.Format(L"Sync offset : Min = %+8.3f ms, Max = %+8.3f ms, StdDev = %7.3f ms, Avr = %7.3f ms, Mode = %d", (double(llMinSyncOffset)/10000.0), (double(llMaxSyncOffset)/10000.0), m_fSyncOffsetStdDev/10000.0, m_fSyncOffsetAvr/10000.0, m_VSyncMode);
+ else
+ strText.Format(L"Sync offset : Mode = %d", m_VSyncMode);
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+ }
+
+ if (bDetailedStats > 1)
+ {
+ strText.Format(L"Jitter : Min = %+8.3f ms, Max = %+8.3f ms, StdDev = %7.3f ms", (double(llMinJitter)/10000.0), (double(llMaxJitter)/10000.0), m_fJitterStdDev/10000.0);
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+ }
+
+ if (m_pAllocator && bDetailedStats > 1)
+ {
+ CDX9SubPicAllocator *pAlloc = (CDX9SubPicAllocator *)m_pAllocator.p;
+ int nFree = 0;
+ int nAlloc = 0;
+ int nSubPic = 0;
+ REFERENCE_TIME QueueNow = 0;
+ REFERENCE_TIME QueueStart = 0;
+ REFERENCE_TIME QueueEnd = 0;
+ if (m_pSubPicQueue)
+ {
+ m_pSubPicQueue->GetStats(nSubPic, QueueNow, QueueStart, QueueEnd);
+ if (QueueStart)
+ QueueStart -= QueueNow;
+ if (QueueEnd)
+ QueueEnd -= QueueNow;
+ }
+ pAlloc->GetStats(nFree, nAlloc);
+ strText.Format(L"Subtitles : Free %d Allocated %d Buffered %d QueueStart %7.3f QueueEnd %7.3f", nFree, nAlloc, nSubPic, (double(QueueStart)/10000000.0), (double(QueueEnd)/10000000.0));
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+ }
+
+ if (bDetailedStats > 1)
+ {
+ if (m_VBlankEndPresent == -100000)
+ strText.Format(L"VBlank Wait : Start %4d End %4d Wait %7.3f ms Offset %4d Max %4d", m_VBlankStartWait, m_VBlankEndWait, (double(m_VBlankWaitTime)/10000.0), m_VBlankMin, m_VBlankMax - m_VBlankMin);
+ else
+ strText.Format(L"VBlank Wait : Start %4d End %4d Wait %7.3f ms Offset %4d Max %4d EndPresent %4d", m_VBlankStartWait, m_VBlankEndWait, (double(m_VBlankWaitTime)/10000.0), m_VBlankMin, m_VBlankMax - m_VBlankMin, m_VBlankEndPresent);
+ }
+ else
+ {
+ if (m_VBlankEndPresent == -100000)
+ strText.Format(L"VBlank Wait : Start %4d End %4d", m_VBlankStartWait, m_VBlankEndWait);
+ else
+ strText.Format(L"VBlank Wait : Start %4d End %4d EP %4d", m_VBlankStartWait, m_VBlankEndWait, m_VBlankEndPresent);
+ }
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+
+ BOOL bCompositionEnabled = m_bCompositionEnabled;
- strText.Format(L"Frame rate : %.03f (%I64d µs)", m_fAvrFps, m_rtTimePerFrame / 10);
- m_pFont->DrawText( NULL, strText, -1, &rc, DT_NOCLIP, D3DXCOLOR( 1.0f, 0.0f, 0.0f, 1.0f ));
+ bool bDoVSyncInPresent = (!bCompositionEnabled && !m_bAlternativeVSync) || !s.m_RenderSettings.iVMR9VSync;
- OffsetRect (&rc, 0, 30);
- strText.Format(L"Refresh rate : %d Hz", m_RefreshRate);
- m_pFont->DrawText( NULL, strText, -1, &rc, DT_NOCLIP, D3DXCOLOR( 1.0f, 0.0f, 0.0f, 1.0f ));
+ if (bDetailedStats > 1 && bDoVSyncInPresent)
+ {
+ strText.Format(L"Present Wait : Wait %7.3f ms Min %7.3f ms Max %7.3f ms", (double(m_PresentWaitTime)/10000.0), (double(m_PresentWaitTimeMin)/10000.0), (double(m_PresentWaitTimeMax)/10000.0));
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+ }
- OffsetRect (&rc, 0, 30);
- strText.Format(L"Buffer used : %d, free : %d", m_nUsedBuffer, m_nNbDXSurface - m_nUsedBuffer);
- m_pFont->DrawText( NULL, strText, -1, &rc, DT_NOCLIP, D3DXCOLOR( 1.0f, 0.0f, 0.0f, 1.0f ));
+ if (bDetailedStats > 1)
+ {
+ if (m_WaitForGPUTime)
+ strText.Format(L"Paint Time : Draw %7.3f ms Min %7.3f ms Max %7.3f ms GPU %7.3f ms", (double(m_PaintTime-m_WaitForGPUTime)/10000.0), (double(m_PaintTimeMin)/10000.0), (double(m_PaintTimeMax)/10000.0), (double(m_WaitForGPUTime)/10000.0));
+ else
+ strText.Format(L"Paint Time : Draw %7.3f ms Min %7.3f ms Max %7.3f ms", (double(m_PaintTime-m_WaitForGPUTime)/10000.0), (double(m_PaintTimeMin)/10000.0), (double(m_PaintTimeMax)/10000.0));
+ }
+ else
+ {
+ if (m_WaitForGPUTime)
+ strText.Format(L"Paint Time : Draw %7.3f ms GPU %7.3f ms", (double(m_PaintTime - m_WaitForGPUTime)/10000.0), (double(m_WaitForGPUTime)/10000.0));
+ else
+ strText.Format(L"Paint Time : Draw %7.3f ms", (double(m_PaintTime - m_WaitForGPUTime)/10000.0));
+ }
+ DrawText(rc, strText, 2);
+ OffsetRect (&rc, 0, TextHeight);
+
+ if (bDetailedStats > 1)
+ {
+ strText.Format(L"Raster Status: Wait %7.3f ms Min %7.3f ms Max %7.3f ms", (double(m_RasterStatusWaitTime)/10000.0), (double(m_RasterStatusWaitTimeMin)/10000.0), (double(m_RasterStatusWaitTimeMax)/10000.0));
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
+ }
- OffsetRect (&rc, 0, 30);
- strText.Format(L"Jitter : Min = %+6dµS, Max = %+6dµS", (long)(llMinJitter/10), (long)(llMaxJitter/10));
- m_pFont->DrawText( NULL, strText, -1, &rc, DT_NOCLIP, D3DXCOLOR( 1.0f, 0.0f, 0.0f, 1.0f ));
+ if (bDetailedStats > 1)
+ {
+ if (m_bIsEVR)
+ strText.Format(L"Buffering : Buffered %3d Free %3d Current Surface %3d", m_nUsedBuffer, m_nNbDXSurface - m_nUsedBuffer, m_nCurSurface, m_nVMR9Surfaces, m_iVMR9Surface);
+ else
+ strText.Format(L"Buffering : VMR9Surfaces %3d VMR9Surface %3d", m_nVMR9Surfaces, m_iVMR9Surface);
+ }
+ else
+ strText.Format(L"Buffered : %3d", m_nUsedBuffer);
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
- OffsetRect (&rc, 0, 30);
- strText.Format(L"Video size : %d x %d (AR = %d x %d)", m_NativeVideoSize.cx, m_NativeVideoSize.cy, m_AspectRatio.cx, m_AspectRatio.cy);
- m_pFont->DrawText( NULL, strText, -1, &rc, DT_NOCLIP, D3DXCOLOR( 1.0f, 0.0f, 0.0f, 1.0f ));
+ if (bDetailedStats > 1)
+ {
+ strText.Format(L"Video size : %d x %d (AR = %d x %d)", m_NativeVideoSize.cx, m_NativeVideoSize.cy, m_AspectRatio.cx, m_AspectRatio.cy);
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
- OffsetRect (&rc, 0, 30);
- strText.Format(L"DirectX SDK : %d", AfxGetMyApp()->GetDXSdkRelease());
- m_pFont->DrawText( NULL, strText, -1, &rc, DT_NOCLIP, D3DXCOLOR( 1.0f, 0.0f, 0.0f, 1.0f ));
+ strText.Format(L"%-13s: %s", GetDXVAVersion(), GetDXVADecoderDescription());
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
- OffsetRect (&rc, 0, 30);
- strText.Format(L"%s : %s", GetDXVAVersion(), GetDXVADecoderDescription());
- m_pFont->DrawText( NULL, strText, -1, &rc, DT_NOCLIP, D3DXCOLOR( 1.0f, 0.0f, 0.0f, 1.0f ));
+ strText.Format(L"DirectX SDK : %d", AfxGetMyApp()->GetDXSdkRelease());
+ DrawText(rc, strText, 1);
+ OffsetRect (&rc, 0, TextHeight);
- for (int i=0; i<6; i++)
+ for (int i=0; i<6; i++)
+ {
+ if (m_strStatsMsg[i][0])
+ {
+ DrawText(rc, m_strStatsMsg[i], 1);
+ OffsetRect (&rc, 0, TextHeight);
+ }
+ }
+ }
+ m_pSprite->End();
+ }
+
+ if (m_pLine && bDetailedStats)
+ {
+ D3DXVECTOR2 Points[NB_JITTER];
+ int nIndex;
+
+ int StartX = 0;
+ int StartY = 0;
+ int ScaleX = 1;
+ int ScaleY = 1;
+ int DrawWidth = 625 * ScaleX + 50;
+ int DrawHeight = 500 * ScaleY;
+ int Alpha = 80;
+ StartX = m_WindowRect.Width() - (DrawWidth + 20);
+ StartY = m_WindowRect.Height() - (DrawHeight + 20);
+
+ DrawRect(RGB(0,0,0), Alpha, CRect(StartX, StartY, StartX + DrawWidth, StartY + DrawHeight));
+ // === Jitter Graduation
+// m_pLine->SetWidth(2.2); // Width
+// m_pLine->SetAntialias(1);
+ m_pLine->SetWidth(2.5); // Width
+ m_pLine->SetAntialias(1);
+// m_pLine->SetGLLines(1);
+ m_pLine->Begin();
+
+ for (int i=10; i<500*ScaleY; i+= 20*ScaleY)
{
- OffsetRect (&rc, 0, 30);
- m_pFont->DrawText( NULL, m_strStatsMsg[i], -1, &rc, DT_NOCLIP, D3DXCOLOR( 1.0f, 0.0f, 0.0f, 1.0f ));
+ Points[0].x = (FLOAT)StartX;
+ Points[0].y = (FLOAT)(StartY + i);
+ Points[1].x = (FLOAT)(StartX + ((i-10)%80 ? 50 : 625 * ScaleX));
+ Points[1].y = (FLOAT)(StartY + i);
+ if (i == 250) Points[1].x += 50;
+ m_pLine->Draw (Points, 2, D3DCOLOR_XRGB(100,100,255));
}
+
+ // === Jitter curve
+ if (m_rtTimePerFrame)
+ {
+ for (int i=0; i<NB_JITTER; i++)
+ {
+ nIndex = (m_nNextJitter+1+i) % NB_JITTER;
+ if (nIndex < 0)
+ nIndex += NB_JITTER;
+ double Jitter = m_pllJitter[nIndex] - m_fJitterMean;
+ Points[i].x = (FLOAT)(StartX + (i*5*ScaleX+5));
+ Points[i].y = (FLOAT)(StartY + ((Jitter*ScaleY)/5000.0 + 250.0* ScaleY));
+ }
+ m_pLine->Draw (Points, NB_JITTER, D3DCOLOR_XRGB(255,100,100));
+
+ if (m_bSyncStatsAvailable)
+ {
+ for (int i=0; i<NB_JITTER; i++)
+ {
+ nIndex = (m_nNextSyncOffset+1+i) % NB_JITTER;
+ if (nIndex < 0)
+ nIndex += NB_JITTER;
+ Points[i].x = (FLOAT)(StartX + (i*5*ScaleX+5));
+ Points[i].y = (FLOAT)(StartY + ((m_pllSyncOffset[nIndex]*ScaleY)/5000 + 250*ScaleY));
+ }
+ m_pLine->Draw (Points, NB_JITTER, D3DCOLOR_XRGB(100,200,100));
+ }
+ }
+ m_pLine->End();
}
+
+ // === Text
+
}
STDMETHODIMP CDX9AllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size)
@@ -1276,11 +2899,22 @@ STDMETHODIMP CDX9AllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size) STDMETHODIMP CDX9AllocatorPresenter::SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget)
{
- CAutoLock cAutoLock(this);
+ return SetPixelShader2(pSrcData, pTarget, false);
+}
+
+STDMETHODIMP CDX9AllocatorPresenter::SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace)
+{
+ CAutoLock cRenderLock(&m_RenderLock);
+
+ CAtlList<CExternalPixelShader> *pPixelShaders;
+ if (bScreenSpace)
+ pPixelShaders = &m_pPixelShadersScreenSpace;
+ else
+ pPixelShaders = &m_pPixelShaders;
if(!pSrcData && !pTarget)
{
- m_pPixelShaders.RemoveAll();
+ pPixelShaders->RemoveAll();
m_pD3DDev->SetPixelShader(NULL);
return S_OK;
}
@@ -1288,14 +2922,19 @@ STDMETHODIMP CDX9AllocatorPresenter::SetPixelShader(LPCSTR pSrcData, LPCSTR pTar if(!pSrcData || !pTarget)
return E_INVALIDARG;
+ CExternalPixelShader Shader;
+ Shader.m_SourceData = pSrcData;
+ Shader.m_SourceTarget = pTarget;
+
CComPtr<IDirect3DPixelShader9> pPixelShader;
- HRESULT hr = m_pPSC->CompileShader(pSrcData, "main", pTarget, 0, &pPixelShader);
- if(FAILED(hr)) return hr;
+ HRESULT hr = Shader.Compile(m_pPSC);
+ if(FAILED(hr))
+ return hr;
- m_pPixelShaders.AddTail(pPixelShader);
+ pPixelShaders->AddTail(Shader);
- Paint(true);
+ Paint(false);
return S_OK;
}
@@ -1306,8 +2945,8 @@ STDMETHODIMP CDX9AllocatorPresenter::SetPixelShader(LPCSTR pSrcData, LPCSTR pTar #define MY_USER_ID 0x6ABE51
-CVMR9AllocatorPresenter::CVMR9AllocatorPresenter(HWND hWnd, HRESULT& hr)
- : CDX9AllocatorPresenter(hWnd, hr)
+CVMR9AllocatorPresenter::CVMR9AllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error)
+ : CDX9AllocatorPresenter(hWnd, hr, false, _Error)
, m_fUseInternalTimer(false)
, m_rtPrevStart(-1)
{
@@ -1324,16 +2963,20 @@ STDMETHODIMP CVMR9AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, v __super::NonDelegatingQueryInterface(riid, ppv);
}
-HRESULT CVMR9AllocatorPresenter::CreateDevice()
+HRESULT CVMR9AllocatorPresenter::CreateDevice(CString &_Error)
{
- HRESULT hr = __super::CreateDevice();
- if(FAILED(hr)) return hr;
+ HRESULT hr = __super::CreateDevice(_Error);
+ if(FAILED(hr))
+ return hr;
if(m_pIVMRSurfAllocNotify)
{
HMONITOR hMonitor = m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D));
if(FAILED(hr = m_pIVMRSurfAllocNotify->ChangeD3DDevice(m_pD3DDev, hMonitor)))
+ {
+ _Error += L"m_pIVMRSurfAllocNotify->ChangeD3DDevice failed";
return(false);
+ }
}
return hr;
@@ -1342,6 +2985,7 @@ HRESULT CVMR9AllocatorPresenter::CreateDevice() void CVMR9AllocatorPresenter::DeleteSurfaces()
{
CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
m_pSurfaces.RemoveAll();
@@ -1360,13 +3004,20 @@ class COuterVMR9 {
CComPtr<IUnknown> m_pVMR;
VMR9AlphaBitmap* m_pVMR9AlphaBitmap;
+ CDX9AllocatorPresenter *m_pAllocatorPresenter;
public:
- COuterVMR9(const TCHAR* pName, LPUNKNOWN pUnk, VMR9AlphaBitmap* pVMR9AlphaBitmap) : CUnknown(pName, pUnk)
+ COuterVMR9(const TCHAR* pName, LPUNKNOWN pUnk, VMR9AlphaBitmap* pVMR9AlphaBitmap, CDX9AllocatorPresenter *_pAllocatorPresenter) : CUnknown(pName, pUnk)
{
m_pVMR.CoCreateInstance(CLSID_VideoMixingRenderer9, GetOwner());
m_pVMR9AlphaBitmap = pVMR9AlphaBitmap;
+ m_pAllocatorPresenter = _pAllocatorPresenter;
+ }
+
+ ~COuterVMR9()
+ {
+ m_pVMR = NULL;
}
DECLARE_IUNKNOWN;
@@ -1610,6 +3261,7 @@ public: STDMETHODIMP GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms)
{
CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
memcpy (pBmpParms, m_pVMR9AlphaBitmap, sizeof(VMR9AlphaBitmap));
return S_OK;
}
@@ -1617,16 +3269,20 @@ public: STDMETHODIMP SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms)
{
CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
memcpy (m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
+ m_pAllocatorPresenter->UpdateAlphaBitmap();
return S_OK;
}
STDMETHODIMP UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms)
{
CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
memcpy (m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
+ m_pAllocatorPresenter->UpdateAlphaBitmap();
return S_OK;
}
};
@@ -1641,14 +3297,14 @@ STDMETHODIMP CVMR9AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer) do
{
- CMacrovisionKicker* pMK = new CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
+ CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
- pMK->SetInner((IUnknown*)(INonDelegatingUnknown*)new COuterVMR9(NAME("COuterVMR9"), pUnk, &m_VMR9AlphaBitmap));
+
+ COuterVMR9 *pOuter = DNew COuterVMR9(NAME("COuterVMR9"), pUnk, &m_VMR9AlphaBitmap, this);
+
+
+ pMK->SetInner((IUnknown*)(INonDelegatingUnknown*)pOuter);
CComQIPtr<IBaseFilter> pBF = pUnk;
-/*
- CComQIPtr<IBaseFilter> pBF = (IUnknown*)(INonDelegatingUnknown*)new COuterVMR9(NAME("COuterVMR9"), NULL);
- if(!pBF) pBF.CoCreateInstance(CLSID_VideoMixingRenderer9);
-*/
CComPtr<IPin> pPin = GetFirstPin(pBF);
CComQIPtr<IMemInputPin> pMemInputPin = pPin;
@@ -1711,6 +3367,7 @@ STDMETHODIMP_(void) CVMR9AllocatorPresenter::SetTime(REFERENCE_TIME rtNow) STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9AllocationInfo* lpAllocInfo, DWORD* lpNumBuffers)
{
+
if(!lpAllocInfo || !lpNumBuffers)
return E_POINTER;
@@ -1723,6 +3380,15 @@ STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9A DeleteSurfaces();
+ int nOriginal = *lpNumBuffers;
+
+ if (*lpNumBuffers == 1)
+ {
+ *lpNumBuffers = 4;
+ m_nVMR9Surfaces = 4;
+ }
+ else
+ m_nVMR9Surfaces = 0;
m_pSurfaces.SetCount(*lpNumBuffers);
int w = lpAllocInfo->dwWidth;
@@ -1736,6 +3402,8 @@ STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9A hr = m_pIVMRSurfAllocNotify->AllocateSurfaceHelper(lpAllocInfo, lpNumBuffers, &m_pSurfaces[0]);
if(FAILED(hr)) return hr;
+ m_pSurfaces.SetCount(*lpNumBuffers);
+
m_NativeVideoSize = m_AspectRatio = CSize(w, h);
int arx = lpAllocInfo->szAspectRatio.cx, ary = lpAllocInfo->szAspectRatio.cy;
if(arx > 0 && ary > 0) m_AspectRatio.SetSize(arx, ary);
@@ -1755,6 +3423,11 @@ STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9A hr = m_pD3DDev->ColorFill(m_pVideoSurface[m_nCurSurface], NULL, 0);
+ if (m_nVMR9Surfaces && m_nVMR9Surfaces != *lpNumBuffers)
+ m_nVMR9Surfaces = *lpNumBuffers;
+ *lpNumBuffers = min(nOriginal, *lpNumBuffers);
+ m_iVMR9Surface = 0;
+
return hr;
}
@@ -1772,9 +3445,19 @@ STDMETHODIMP CVMR9AllocatorPresenter::GetSurface(DWORD_PTR dwUserID, DWORD Surfa if(SurfaceIndex >= m_pSurfaces.GetCount())
return E_FAIL;
- CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
- (*lplpSurface = m_pSurfaces[SurfaceIndex])->AddRef();
+ if (m_nVMR9Surfaces)
+ {
+ ++m_iVMR9Surface;
+ m_iVMR9Surface = m_iVMR9Surface % m_nVMR9Surfaces;
+ (*lplpSurface = m_pSurfaces[m_iVMR9Surface + SurfaceIndex])->AddRef();
+ }
+ else
+ {
+ m_iVMR9Surface = SurfaceIndex;
+ (*lplpSurface = m_pSurfaces[SurfaceIndex])->AddRef();
+ }
return S_OK;
}
@@ -1782,7 +3465,8 @@ STDMETHODIMP CVMR9AllocatorPresenter::GetSurface(DWORD_PTR dwUserID, DWORD Surfa STDMETHODIMP CVMR9AllocatorPresenter::AdviseNotify(IVMRSurfaceAllocatorNotify9* lpIVMRSurfAllocNotify)
{
CAutoLock cAutoLock(this);
-
+ CAutoLock cRenderLock(&m_RenderLock);
+
m_pIVMRSurfAllocNotify = lpIVMRSurfAllocNotify;
HRESULT hr;
@@ -1798,6 +3482,7 @@ STDMETHODIMP CVMR9AllocatorPresenter::AdviseNotify(IVMRSurfaceAllocatorNotify9* STDMETHODIMP CVMR9AllocatorPresenter::StartPresenting(DWORD_PTR dwUserID)
{
CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
ASSERT(m_pD3DDev);
@@ -1836,6 +3521,7 @@ STDMETHODIMP CVMR9AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMR9Prese return E_POINTER;
CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
CComPtr<IDirect3DTexture9> pTexture;
lpPresInfo->lpSurf->GetContainer(IID_IDirect3DTexture9, (void**)&pTexture);
@@ -1843,7 +3529,8 @@ STDMETHODIMP CVMR9AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMR9Prese if(pTexture)
{
m_pVideoSurface[m_nCurSurface] = lpPresInfo->lpSurf;
- if(m_pVideoTexture[m_nCurSurface]) m_pVideoTexture[m_nCurSurface] = pTexture;
+ if(m_pVideoTexture[m_nCurSurface])
+ m_pVideoTexture[m_nCurSurface] = pTexture;
}
else
{
@@ -1939,8 +3626,8 @@ STDMETHODIMP CVMR9AllocatorPresenter::GetBorderColor(COLORREF* lpClr) // CRM9AllocatorPresenter
//
-CRM9AllocatorPresenter::CRM9AllocatorPresenter(HWND hWnd, HRESULT& hr)
- : CDX9AllocatorPresenter(hWnd, hr)
+CRM9AllocatorPresenter::CRM9AllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error)
+ : CDX9AllocatorPresenter(hWnd, hr, false, _Error)
{
}
@@ -1956,6 +3643,7 @@ STDMETHODIMP CRM9AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, vo HRESULT CRM9AllocatorPresenter::AllocSurfaces()
{
CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
m_pVideoSurfaceOff = NULL;
m_pVideoSurfaceYUY2 = NULL;
@@ -1985,6 +3673,7 @@ HRESULT CRM9AllocatorPresenter::AllocSurfaces() void CRM9AllocatorPresenter::DeleteSurfaces()
{
CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
m_pVideoSurfaceOff = NULL;
m_pVideoSurfaceYUY2 = NULL;
__super::DeleteSurfaces();
@@ -2127,6 +3816,7 @@ STDMETHODIMP CRM9AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* STDMETHODIMP CRM9AllocatorPresenter::BeginOptimizedBlt(RMABitmapInfoHeader* pBitmapInfo)
{
CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
DeleteSurfaces();
m_NativeVideoSize = m_AspectRatio = CSize(pBitmapInfo->biWidth, abs(pBitmapInfo->biHeight));
if(FAILED(AllocSurfaces())) return E_FAIL;
@@ -2158,8 +3848,8 @@ STDMETHODIMP CRM9AllocatorPresenter::GetPreferredFormat(REF(RMA_COMPRESSION_TYPE // CQT9AllocatorPresenter
//
-CQT9AllocatorPresenter::CQT9AllocatorPresenter(HWND hWnd, HRESULT& hr)
- : CDX9AllocatorPresenter(hWnd, hr)
+CQT9AllocatorPresenter::CQT9AllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error)
+ : CDX9AllocatorPresenter(hWnd, hr, false, _Error)
{
}
@@ -2198,6 +3888,7 @@ void CQT9AllocatorPresenter::DeleteSurfaces() STDMETHODIMP CQT9AllocatorPresenter::BeginBlt(const BITMAP& bm)
{
CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
DeleteSurfaces();
m_NativeVideoSize = m_AspectRatio = CSize(bm.bmWidth, abs(bm.bmHeight));
if(FAILED(AllocSurfaces())) return E_FAIL;
@@ -2266,11 +3957,15 @@ STDMETHODIMP CQT9AllocatorPresenter::DoBlt(const BITMAP& bm) // CDXRAllocatorPresenter
//
-CDXRAllocatorPresenter::CDXRAllocatorPresenter(HWND hWnd, HRESULT& hr)
- : ISubPicAllocatorPresenterImpl(hWnd, hr)
+CDXRAllocatorPresenter::CDXRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error)
+ : ISubPicAllocatorPresenterImpl(hWnd, hr, &_Error)
, m_ScreenSize(0, 0)
{
- if(FAILED(hr)) return;
+ if(FAILED(hr))
+ {
+ _Error += L"ISubPicAllocatorPresenterImpl failed\n";
+ return;
+ }
hr = S_OK;
}
@@ -2326,6 +4021,10 @@ HRESULT CDXRAllocatorPresenter::SetDevice(IDirect3DDevice9* pD3DDev) case 3: size.SetSize(640, 480); break;
case 4: size.SetSize(512, 384); break;
case 5: size.SetSize(384, 288); break;
+ case 6: size.SetSize(2560, 1600); break;
+ case 7: size.SetSize(1920, 1080); break;
+ case 8: size.SetSize(1320, 900); break;
+ case 9: size.SetSize(1280, 720); break;
}
if(m_pAllocator)
@@ -2334,7 +4033,7 @@ HRESULT CDXRAllocatorPresenter::SetDevice(IDirect3DDevice9* pD3DDev) }
else
{
- m_pAllocator = new CDX9SubPicAllocator(pD3DDev, size, AfxGetAppSettings().fSPCPow2Tex);
+ m_pAllocator = DNew CDX9SubPicAllocator(pD3DDev, size, AfxGetAppSettings().fSPCPow2Tex);
if(!m_pAllocator)
return E_FAIL;
}
@@ -2342,8 +4041,8 @@ HRESULT CDXRAllocatorPresenter::SetDevice(IDirect3DDevice9* pD3DDev) HRESULT hr = S_OK;
m_pSubPicQueue = AfxGetAppSettings().nSPCSize > 0
- ? (ISubPicQueue*)new CSubPicQueue(AfxGetAppSettings().nSPCSize, m_pAllocator, &hr)
- : (ISubPicQueue*)new CSubPicQueueNoThread(m_pAllocator, &hr);
+ ? (ISubPicQueue*)DNew CSubPicQueue(AfxGetAppSettings().nSPCSize, AfxGetAppSettings().fSPCDisableAnim, m_pAllocator, &hr)
+ : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
if(!m_pSubPicQueue || FAILED(hr))
return E_FAIL;
@@ -2376,7 +4075,7 @@ STDMETHODIMP CDXRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer) CComQIPtr<ISubRender> pSR = m_pDXR;
if(!pSR) {m_pDXR = NULL; return E_FAIL;}
- m_pSRCB = new CSubRenderCallback(this);
+ m_pSRCB = DNew CSubRenderCallback(this);
if(FAILED(pSR->SetCallback(m_pSRCB))) {m_pDXR = NULL; return E_FAIL;}
(*ppRenderer = this)->AddRef();
diff --git a/src/apps/mplayerc/EVRAllocatorPresenter.cpp b/src/apps/mplayerc/EVRAllocatorPresenter.cpp index 06733070d..f3d93c042 100644 --- a/src/apps/mplayerc/EVRAllocatorPresenter.cpp +++ b/src/apps/mplayerc/EVRAllocatorPresenter.cpp @@ -53,8 +53,10 @@ #if (0) // Set to 1 to activate EVR traces
#define TRACE_EVR TRACE
+ #define TRACE_EVR2 TRACE
#else
#define TRACE_EVR
+ #define TRACE_EVR2 TRACE
#endif
typedef enum
@@ -109,22 +111,144 @@ MFVideoArea MakeArea(float x, float y, DWORD width, DWORD height) /// === Outer EVR
+class CEVRAllocatorPresenter;
+
class COuterEVR
: public CUnknown
, public IVMRffdshow9
, public IVMRMixerBitmap9
+ , public IBaseFilter
{
CComPtr<IUnknown> m_pEVR;
VMR9AlphaBitmap* m_pVMR9AlphaBitmap;
+ CEVRAllocatorPresenter *m_pAllocatorPresenter;
public:
- COuterEVR(const TCHAR* pName, LPUNKNOWN pUnk, HRESULT& hr, VMR9AlphaBitmap* pVMR9AlphaBitmap) : CUnknown(pName, pUnk)
+ // IBaseFilter
+ virtual HRESULT STDMETHODCALLTYPE EnumPins(__out IEnumPins **ppEnum)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->EnumPins(ppEnum);
+ return E_NOTIMPL;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE FindPin(LPCWSTR Id, __out IPin **ppPin)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->FindPin(Id, ppPin);
+ return E_NOTIMPL;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE QueryFilterInfo(__out FILTER_INFO *pInfo)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->QueryFilterInfo(pInfo);
+ return E_NOTIMPL;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE JoinFilterGraph(__in_opt IFilterGraph *pGraph, __in_opt LPCWSTR pName)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->JoinFilterGraph(pGraph, pName);
+ return E_NOTIMPL;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE QueryVendorInfo(__out LPWSTR *pVendorInfo)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->QueryVendorInfo(pVendorInfo);
+ return E_NOTIMPL;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE Stop( void)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->Stop();
+ return E_NOTIMPL;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE Pause( void)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->Pause();
+ return E_NOTIMPL;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE Run( REFERENCE_TIME tStart)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->Run(tStart);
+ return E_NOTIMPL;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE GetState( DWORD dwMilliSecsTimeout, __out FILTER_STATE *State);
+
+ virtual HRESULT STDMETHODCALLTYPE SetSyncSource(__in_opt IReferenceClock *pClock)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->SetSyncSource(pClock);
+ return E_NOTIMPL;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE GetSyncSource(__deref_out_opt IReferenceClock **pClock)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->GetSyncSource(pClock);
+ return E_NOTIMPL;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE GetClassID(__RPC__out CLSID *pClassID)
+ {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->GetClassID(pClassID);
+ return E_NOTIMPL;
+ }
+
+ COuterEVR(const TCHAR* pName, LPUNKNOWN pUnk, HRESULT& hr, VMR9AlphaBitmap* pVMR9AlphaBitmap, CEVRAllocatorPresenter *pAllocatorPresenter) : CUnknown(pName, pUnk)
{
hr = m_pEVR.CoCreateInstance(CLSID_EnhancedVideoRenderer, GetOwner());
m_pVMR9AlphaBitmap = pVMR9AlphaBitmap;
+ m_pAllocatorPresenter = pAllocatorPresenter;
+
+
}
+ ~COuterEVR();
+
DECLARE_IUNKNOWN;
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
@@ -133,6 +257,24 @@ public: if(riid == __uuidof(IVMRMixerBitmap9))
return GetInterface((IVMRMixerBitmap9*)this, ppv);
+ if (riid == __uuidof(IBaseFilter))
+ {
+ return GetInterface((IBaseFilter*)this, ppv);
+ }
+
+ if (riid == __uuidof(IMediaFilter))
+ {
+ return GetInterface((IMediaFilter*)this, ppv);
+ }
+ if (riid == __uuidof(IPersist))
+ {
+ return GetInterface((IPersist*)this, ppv);
+ }
+ if (riid == __uuidof(IBaseFilter))
+ {
+ return GetInterface((IBaseFilter*)this, ppv);
+ }
+
hr = m_pEVR ? m_pEVR->QueryInterface(riid, ppv) : E_NOINTERFACE;
if(m_pEVR && FAILED(hr))
{
@@ -151,28 +293,11 @@ public: }
// IVMRMixerBitmap9
- STDMETHODIMP GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms)
- {
- CheckPointer(pBmpParms, E_POINTER);
- memcpy (pBmpParms, m_pVMR9AlphaBitmap, sizeof(VMR9AlphaBitmap));
- return S_OK;
- }
+ STDMETHODIMP GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms);
- STDMETHODIMP SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms)
- {
- CheckPointer(pBmpParms, E_POINTER);
- memcpy (m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
- m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
- return S_OK;
- }
+ STDMETHODIMP SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms);
- STDMETHODIMP UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms)
- {
- CheckPointer(pBmpParms, E_POINTER);
- memcpy (m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
- m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
- return S_OK;
- }
+ STDMETHODIMP UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms);
};
@@ -198,7 +323,7 @@ class CEVRAllocatorPresenter : */
{
public:
- CEVRAllocatorPresenter(HWND hWnd, HRESULT& hr);
+ CEVRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error);
~CEVRAllocatorPresenter(void);
DECLARE_IUNKNOWN;
@@ -217,6 +342,9 @@ public: STDMETHODIMP STDMETHODCALLTYPE OnClockRestart(/* [in] */ MFTIME hnsSystemTime);
STDMETHODIMP STDMETHODCALLTYPE OnClockSetRate(/* [in] */ MFTIME hnsSystemTime, /* [in] */ float flRate);
+ // IBaseFilter delegate
+ bool GetState( DWORD dwMilliSecsTimeout, FILTER_STATE *State, HRESULT &_ReturnValue);
+
// IQualProp (EVR statistics window)
STDMETHODIMP get_FramesDroppedInRenderer (int *pcFrames);
STDMETHODIMP get_FramesDrawn (int *pcFramesDrawn);
@@ -289,16 +417,26 @@ public: protected :
void OnResetDevice();
+ virtual void OnVBlankFinished(bool fAll, LONGLONG PerformanceCounter);
+
+ double m_ModeratedTime;
+ LONGLONG m_ModeratedTimeLast;
+ LONGLONG m_ModeratedClockLast;
+ LONGLONG m_ModeratedTimer;
+ MFCLOCK_STATE m_LastClockState;
+ LONGLONG GetClockTime(LONGLONG PerformanceCounter);
+
private :
typedef enum
{
- Started,
- Stopped,
- Paused,
- Shutdown
+ Started = State_Running,
+ Stopped = State_Stopped,
+ Paused = State_Paused,
+ Shutdown = State_Running + 1
} RENDER_STATE;
+ COuterEVR *m_pOuterEVR;
CComPtr<IMFClock> m_pClock;
CComPtr<IDirect3DDeviceManager9> m_pD3DManager;
CComPtr<IMFTransform> m_pMixer;
@@ -310,30 +448,54 @@ private : HANDLE m_hEvtQuit; // Stop rendering thread event
- HANDLE m_hEvtPresent; // Render next frame (cued order)
- HANDLE m_hEvtFrameTimer; // Render next frame (timer based)
+ bool m_bEvtQuit;
HANDLE m_hEvtFlush; // Discard all buffers
- HANDLE m_hSemPicture; // Indicate present of buffered frames
+ bool m_bEvtFlush;
bool m_fUseInternalTimer;
+ int32 m_LastSetOutputRange;
+ bool m_bPendingRenegotiate;
+ bool m_bPendingMediaFinished;
HANDLE m_hThread;
+ HANDLE m_hGetMixerThread;
RENDER_STATE m_nRenderState;
+ CCritSec m_SampleQueueLock;
+ CCritSec m_ImageProcessingLock;
+
CInterfaceList<IMFSample, &IID_IMFSample> m_FreeSamples;
CInterfaceList<IMFSample, &IID_IMFSample> m_ScheduledSamples;
+ IMFSample * m_pCurrentDisplaydSample;
bool m_bWaitingSample;
+ bool m_bLastSampleOffsetValid;
+ LONGLONG m_LastScheduledSampleTime;
+ double m_LastScheduledSampleTimeFP;
+ LONGLONG m_LastScheduledUncorrectedSampleTime;
+ LONGLONG m_MaxSampleDuration;
+ LONGLONG m_LastSampleOffset;
+ LONGLONG m_VSyncOffsetHistory[5];
+ LONGLONG m_LastPredictedSync;
+ int m_VSyncOffsetHistoryPos;
UINT m_nResetToken;
- UINT m_nStepCount;
+ int m_nStepCount;
+
+ bool m_bSignaledStarvation;
+ LONGLONG m_StarvationClock;
// Stats variable for IQualProp
UINT m_pcFrames;
+ UINT m_nDroppedUpdate;
UINT m_pcFramesDrawn; // Retrieves the number of frames drawn since streaming started
UINT m_piAvg;
UINT m_piDev;
- HRESULT GetImageFromMixer();
+
+ void GetMixerThread();
+ static DWORD WINAPI GetMixerThreadStatic(LPVOID lpParam);
+
+ bool GetImageFromMixer();
void RenderThread();
static DWORD WINAPI PresentThread(LPVOID lpParam);
void ResetStats();
@@ -345,10 +507,11 @@ private : void RemoveAllSamples();
HRESULT GetFreeSample(IMFSample** ppSample);
- HRESULT GetScheduledSample(IMFSample** ppSample);
+ HRESULT GetScheduledSample(IMFSample** ppSample, int &_Count);
void MoveToFreeList(IMFSample* pSample, bool bTail);
- void MoveToScheduledList(IMFSample* pSample);
+ void MoveToScheduledList(IMFSample* pSample, bool _bSorted);
void FlushSamples();
+ void FlushSamplesInternal();
// === Media type negociation functions
HRESULT RenegotiateMediaType();
@@ -361,6 +524,12 @@ private : PTR_MFCreateDXSurfaceBuffer pfMFCreateDXSurfaceBuffer;
PTR_MFCreateVideoSampleFromSurface pfMFCreateVideoSampleFromSurface;
PTR_MFCreateVideoMediaType pfMFCreateVideoMediaType;
+
+#if 0
+ HRESULT (__stdcall *pMFCreateMediaType)(__deref_out IMFMediaType** ppMFType);
+ HRESULT (__stdcall *pMFInitMediaTypeFromAMMediaType)(__in IMFMediaType *pMFType, __in const AM_MEDIA_TYPE *pAMType);
+ HRESULT (__stdcall *pMFInitAMMediaTypeFromMFMediaType)(__in IMFMediaType *pMFType, __in GUID guidFormatBlockType, __inout AM_MEDIA_TYPE *pAMType);
+#endif
PTR_AvSetMmThreadCharacteristicsW pfAvSetMmThreadCharacteristicsW;
PTR_AvSetMmThreadPriority pfAvSetMmThreadPriority;
@@ -368,43 +537,111 @@ private : };
+HRESULT STDMETHODCALLTYPE COuterEVR::GetState( DWORD dwMilliSecsTimeout, __out FILTER_STATE *State)
+{
+ HRESULT ReturnValue;
+ if (m_pAllocatorPresenter->GetState(dwMilliSecsTimeout, State, ReturnValue))
+ return ReturnValue;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR)
+ m_pEVR->QueryInterface(&pEVRBase);
+ if (pEVRBase)
+ return pEVRBase->GetState(dwMilliSecsTimeout, State);
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP COuterEVR::GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms)
+{
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy (pBmpParms, m_pVMR9AlphaBitmap, sizeof(VMR9AlphaBitmap));
+ return S_OK;
+}
+
+STDMETHODIMP COuterEVR::SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms)
+{
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy (m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
+ m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
+ m_pAllocatorPresenter->UpdateAlphaBitmap();
+ return S_OK;
+}
+
+STDMETHODIMP COuterEVR::UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms)
+{
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy (m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
+ m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
+ m_pAllocatorPresenter->UpdateAlphaBitmap();
+ return S_OK;
+}
+
+COuterEVR::~COuterEVR()
+{
+}
+
+
+CString GetWindowsErrorMessage(HRESULT _Error, HMODULE _Module);
+
HRESULT CreateEVR(const CLSID& clsid, HWND hWnd, ISubPicAllocatorPresenter** ppAP)
{
HRESULT hr = E_FAIL;
if (clsid == CLSID_EVRAllocatorPresenter)
{
- *ppAP = new CEVRAllocatorPresenter(hWnd, hr);
+ CString Error;
+ *ppAP = DNew CEVRAllocatorPresenter(hWnd, hr, Error);
(*ppAP)->AddRef();
if(FAILED(hr))
{
+ Error += L"\n";
+ Error += GetWindowsErrorMessage(hr, NULL);
+ MessageBox(hWnd, Error, L"Error creating EVR Custom renderer", MB_OK | MB_ICONERROR);
(*ppAP)->Release();
*ppAP = NULL;
}
+ else if (!Error.IsEmpty())
+ {
+ MessageBox(hWnd, Error, L"Warning creating EVR Custom renderer", MB_OK|MB_ICONWARNING);
+ }
}
return hr;
}
-CEVRAllocatorPresenter::CEVRAllocatorPresenter(HWND hWnd, HRESULT& hr)
- : CDX9AllocatorPresenter(hWnd, hr)
+CEVRAllocatorPresenter::CEVRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error)
+ : CDX9AllocatorPresenter(hWnd, hr, true, _Error)
{
HMODULE hLib;
AppSettings& s = AfxGetAppSettings();
- if (FAILED (hr)) return;
-
- // Load EVR specifics DLLs
- hLib = LoadLibrary (L"dxva2.dll");
- pfDXVA2CreateDirect3DDeviceManager9 = hLib ? (PTR_DXVA2CreateDirect3DDeviceManager9) GetProcAddress (hLib, "DXVA2CreateDirect3DDeviceManager9") : NULL;
m_nResetToken = 0;
m_hThread = INVALID_HANDLE_VALUE;
- m_hSemPicture = INVALID_HANDLE_VALUE;
- m_hEvtPresent = INVALID_HANDLE_VALUE;
- m_hEvtFrameTimer = INVALID_HANDLE_VALUE;
+ m_hGetMixerThread= INVALID_HANDLE_VALUE;
m_hEvtFlush = INVALID_HANDLE_VALUE;
m_hEvtQuit = INVALID_HANDLE_VALUE;
+ m_bEvtQuit = 0;
+ m_bEvtFlush = 0;
+ m_ModeratedTime = 0;
+ m_ModeratedTimeLast = -1;
+ m_ModeratedClockLast = -1;
+
+
+ m_bNeedPendingResetDevice = true;
+
+ if (FAILED (hr))
+ {
+ _Error += L"DX9AllocatorPresenter failed\n";
+
+ return;
+ }
+
+ // Load EVR specifics DLLs
+ hLib = LoadLibrary (L"dxva2.dll");
+ pfDXVA2CreateDirect3DDeviceManager9 = hLib ? (PTR_DXVA2CreateDirect3DDeviceManager9) GetProcAddress (hLib, "DXVA2CreateDirect3DDeviceManager9") : NULL;
// Load EVR functions
hLib = LoadLibrary (L"evr.dll");
@@ -414,10 +651,32 @@ CEVRAllocatorPresenter::CEVRAllocatorPresenter(HWND hWnd, HRESULT& hr) if (!pfDXVA2CreateDirect3DDeviceManager9 || !pfMFCreateDXSurfaceBuffer || !pfMFCreateVideoSampleFromSurface || !pfMFCreateVideoMediaType)
{
+ if (!pfDXVA2CreateDirect3DDeviceManager9)
+ _Error += L"Could not find DXVA2CreateDirect3DDeviceManager9 (dxva2.dll)\n";
+ if (!pfMFCreateDXSurfaceBuffer)
+ _Error += L"Could not find MFCreateDXSurfaceBuffer (evr.dll)\n";
+ if (!pfMFCreateVideoSampleFromSurface)
+ _Error += L"Could not find MFCreateVideoSampleFromSurface (evr.dll)\n";
+ if (!pfMFCreateVideoMediaType)
+ _Error += L"Could not find MFCreateVideoMediaType (evr.dll)\n";
hr = E_FAIL;
return;
}
+ // Load mfplat fuctions
+#if 0
+ hLib = LoadLibrary (L"mfplat.dll");
+ (FARPROC &)pMFCreateMediaType = GetProcAddress(hLib, "MFCreateMediaType");
+ (FARPROC &)pMFInitMediaTypeFromAMMediaType = GetProcAddress(hLib, "MFInitMediaTypeFromAMMediaType");
+ (FARPROC &)pMFInitAMMediaTypeFromMFMediaType = GetProcAddress(hLib, "MFInitAMMediaTypeFromMFMediaType");
+
+ if (!pMFCreateMediaType || !pMFInitMediaTypeFromAMMediaType || !pMFInitAMMediaTypeFromMFMediaType)
+ {
+ hr = E_FAIL;
+ return;
+ }
+#endif
+
// Load Vista specifics DLLs
hLib = LoadLibrary (L"AVRT.dll");
pfAvSetMmThreadCharacteristicsW = hLib ? (PTR_AvSetMmThreadCharacteristicsW) GetProcAddress (hLib, "AvSetMmThreadCharacteristicsW") : NULL;
@@ -426,7 +685,16 @@ CEVRAllocatorPresenter::CEVRAllocatorPresenter(HWND hWnd, HRESULT& hr) // Init DXVA manager
hr = pfDXVA2CreateDirect3DDeviceManager9(&m_nResetToken, &m_pD3DManager);
- if (SUCCEEDED (hr)) hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
+ if (SUCCEEDED (hr))
+ {
+ hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
+ if (!SUCCEEDED (hr))
+ {
+ _Error += L"m_pD3DManager->ResetDevice failed\n";
+ }
+ }
+ else
+ _Error += L"DXVA2CreateDirect3DDeviceManager9 failed\n";
CComPtr<IDirectXVideoDecoderService> pDecoderService;
HANDLE hDevice;
@@ -449,11 +717,25 @@ CEVRAllocatorPresenter::CEVRAllocatorPresenter(HWND hWnd, HRESULT& hr) ResetStats();
m_nRenderState = Shutdown;
m_fUseInternalTimer = false;
+ m_LastSetOutputRange = -1;
+ m_bPendingRenegotiate = false;
+ m_bPendingMediaFinished = false;
m_bWaitingSample = false;
+ m_pCurrentDisplaydSample = NULL;
m_nStepCount = 0;
m_dwVideoAspectRatioMode = MFVideoARMode_PreservePicture;
m_dwVideoRenderPrefs = (MFVideoRenderPrefs)0;
m_BorderColor = RGB (0,0,0);
+ m_bSignaledStarvation = false;
+ m_StarvationClock = 0;
+ m_pOuterEVR = NULL;
+ m_LastScheduledSampleTime = -1;
+ m_LastScheduledUncorrectedSampleTime = -1;
+ m_MaxSampleDuration = 0;
+ m_LastSampleOffset = 0;
+ ZeroMemory(m_VSyncOffsetHistory, sizeof(m_VSyncOffsetHistory));
+ m_VSyncOffsetHistoryPos = 0;
+ m_bLastSampleOffsetValid = false;
}
CEVRAllocatorPresenter::~CEVRAllocatorPresenter(void)
@@ -461,6 +743,7 @@ CEVRAllocatorPresenter::~CEVRAllocatorPresenter(void) StopWorkerThreads(); // If not already done...
m_pMediaType = NULL;
m_pClock = NULL;
+
m_pD3DManager = NULL;
}
@@ -468,6 +751,7 @@ CEVRAllocatorPresenter::~CEVRAllocatorPresenter(void) void CEVRAllocatorPresenter::ResetStats()
{
m_pcFrames = 0;
+ m_nDroppedUpdate = 0;
m_pcFramesDrawn = 0;
m_piAvg = 0;
m_piDev = 0;
@@ -494,12 +778,12 @@ void CEVRAllocatorPresenter::StartWorkerThreads() if (m_nRenderState == Shutdown)
{
m_hEvtQuit = CreateEvent (NULL, TRUE, FALSE, NULL);
- m_hEvtPresent = CreateEvent (NULL, FALSE, FALSE, NULL);
- m_hEvtFrameTimer= CreateEvent (NULL, FALSE, FALSE, NULL);
m_hEvtFlush = CreateEvent (NULL, TRUE, FALSE, NULL);
- m_hSemPicture = CreateSemaphore(NULL, 0, m_nNbDXSurface, NULL);
m_hThread = ::CreateThread(NULL, 0, PresentThread, (LPVOID)this, 0, &dwThreadId);
+ SetThreadPriority(m_hThread, THREAD_PRIORITY_TIME_CRITICAL);
+ m_hGetMixerThread = ::CreateThread(NULL, 0, GetMixerThreadStatic, (LPVOID)this, 0, &dwThreadId);
+ SetThreadPriority(m_hGetMixerThread, THREAD_PRIORITY_HIGHEST);
m_nRenderState = Stopped;
TRACE_EVR ("Worker threads started...\n");
@@ -511,35 +795,54 @@ void CEVRAllocatorPresenter::StopWorkerThreads() if (m_nRenderState != Shutdown)
{
SetEvent (m_hEvtFlush);
+ m_bEvtFlush = true;
SetEvent (m_hEvtQuit);
+ m_bEvtQuit = true;
if ((m_hThread != INVALID_HANDLE_VALUE) && (WaitForSingleObject (m_hThread, 10000) == WAIT_TIMEOUT))
{
ASSERT (FALSE);
TerminateThread (m_hThread, 0xDEAD);
}
+ if ((m_hGetMixerThread != INVALID_HANDLE_VALUE) && (WaitForSingleObject (m_hGetMixerThread, 10000) == WAIT_TIMEOUT))
+ {
+ ASSERT (FALSE);
+ TerminateThread (m_hGetMixerThread, 0xDEAD);
+ }
if (m_hThread != INVALID_HANDLE_VALUE) CloseHandle (m_hThread);
- if (m_hSemPicture != INVALID_HANDLE_VALUE) CloseHandle (m_hSemPicture);
- if (m_hEvtPresent != INVALID_HANDLE_VALUE) CloseHandle (m_hEvtPresent);
- if (m_hEvtFrameTimer != INVALID_HANDLE_VALUE) CloseHandle (m_hEvtFrameTimer);
+ if (m_hGetMixerThread != INVALID_HANDLE_VALUE) CloseHandle (m_hGetMixerThread);
if (m_hEvtFlush != INVALID_HANDLE_VALUE) CloseHandle (m_hEvtFlush);
if (m_hEvtQuit != INVALID_HANDLE_VALUE) CloseHandle (m_hEvtQuit);
+ m_bEvtFlush = false;
+ m_bEvtQuit = false;
+
+
TRACE_EVR ("Worker threads stopped...\n");
}
m_nRenderState = Shutdown;
}
+
STDMETHODIMP CEVRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
{
+ CheckPointer(ppRenderer, E_POINTER);
+
+ *ppRenderer = NULL;
+
HRESULT hr = E_FAIL;
do
{
- CMacrovisionKicker* pMK = new CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
+ CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
- pMK->SetInner((IUnknown*)(INonDelegatingUnknown*)new COuterEVR(NAME("COuterEVR"), pUnk, hr, &m_VMR9AlphaBitmap));
- CComQIPtr<IBaseFilter> pBF = pUnk;
+
+ COuterEVR *pOuterEVR = DNew COuterEVR(NAME("COuterEVR"), pUnk, hr, &m_VMR9AlphaBitmap, this);
+ m_pOuterEVR = pOuterEVR;
+
+ pMK->SetInner((IUnknown*)(INonDelegatingUnknown*)pOuterEVR);
+ CComQIPtr<IBaseFilter> pBF = pUnk;
+
if (FAILED (hr)) break;
// Set EVR custom presenter
@@ -548,14 +851,19 @@ STDMETHODIMP CEVRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer) CComQIPtr<IMFGetService, &__uuidof(IMFGetService)> pMFGS = pBF;
hr = pMFGS->GetService (MR_VIDEO_RENDER_SERVICE, IID_IMFVideoRenderer, (void**)&pMFVR);
+
if(SUCCEEDED(hr)) hr = QueryInterface (__uuidof(IMFVideoPresenter), (void**)&pVP);
if(SUCCEEDED(hr)) hr = pMFVR->InitializeRenderer (NULL, pVP);
+#if 1
CComPtr<IPin> pPin = GetFirstPin(pBF);
CComQIPtr<IMemInputPin> pMemInputPin = pPin;
// No NewSegment : no chocolate :o)
m_fUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
+#else
+ m_fUseInternalTimer = false;
+#endif
if(FAILED(hr))
*ppRenderer = NULL;
@@ -611,8 +919,9 @@ STDMETHODIMP CEVRAllocatorPresenter::OnClockStart(MFTIME hnsSystemTime, LONGLON {
m_nRenderState = Started;
- SetEvent(m_hEvtPresent);
TRACE_EVR ("OnClockStart hnsSystemTime = %I64d, llClockStartOffset = %I64d\n", hnsSystemTime, llClockStartOffset);
+ m_ModeratedTimeLast = -1;
+ m_ModeratedClockLast = -1;
return S_OK;
}
@@ -622,22 +931,27 @@ STDMETHODIMP CEVRAllocatorPresenter::OnClockStop(MFTIME hnsSystemTime) TRACE_EVR ("OnClockStop hnsSystemTime = %I64d\n", hnsSystemTime);
m_nRenderState = Stopped;
+ m_ModeratedClockLast = -1;
+ m_ModeratedTimeLast = -1;
return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::OnClockPause(MFTIME hnsSystemTime)
{
TRACE_EVR ("OnClockPause hnsSystemTime = %I64d\n", hnsSystemTime);
- m_nRenderState = Paused;
-
+ if (!m_bSignaledStarvation)
+ m_nRenderState = Paused;
+ m_ModeratedTimeLast = -1;
+ m_ModeratedClockLast = -1;
return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::OnClockRestart(MFTIME hnsSystemTime)
{
m_nRenderState = Started;
- SetEvent(m_hEvtPresent);
+ m_ModeratedTimeLast = -1;
+ m_ModeratedClockLast = -1;
TRACE_EVR ("OnClockRestart hnsSystemTime = %I64d\n", hnsSystemTime);
return S_OK;
@@ -650,6 +964,25 @@ STDMETHODIMP CEVRAllocatorPresenter::OnClockSetRate(MFTIME hnsSystemTime, float return E_NOTIMPL;
}
+// IBaseFilter delegate
+bool CEVRAllocatorPresenter::GetState( DWORD dwMilliSecsTimeout, FILTER_STATE *State, HRESULT &_ReturnValue)
+{
+ CAutoLock lock(&m_SampleQueueLock);
+
+ if (m_bSignaledStarvation)
+ {
+ int nSamples = max(m_nNbDXSurface / 2, 1);
+ if (m_ScheduledSamples.GetCount() < nSamples || m_LastSampleOffset < -m_rtTimePerFrame*2)
+ {
+ *State = (FILTER_STATE)Paused;
+ _ReturnValue = VFW_S_STATE_INTERMEDIATE;
+ return true;
+ }
+ m_bSignaledStarvation = false;
+ }
+ return false;
+}
+
// IQualProp
STDMETHODIMP CEVRAllocatorPresenter::get_FramesDroppedInRenderer(int *pcFrames)
{
@@ -668,17 +1001,17 @@ STDMETHODIMP CEVRAllocatorPresenter::get_AvgFrameRate(int *piAvgFrameRate) }
STDMETHODIMP CEVRAllocatorPresenter::get_Jitter(int *iJitter)
{
- *iJitter = (int)(m_pllJitter[m_nNextJitter]/5000);
+ *iJitter = (int)((m_fJitterStdDev/10000.0) + 0.5);
return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::get_AvgSyncOffset(int *piAvg)
{
- *piAvg = m_piAvg;
+ *piAvg = (int)((m_fSyncOffsetAvr/10000.0) + 0.5);
return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::get_DevSyncOffset(int *piDev)
{
- *piDev = m_piDev;
+ *piDev = (int)((m_fSyncOffsetStdDev/10000.0) + 0.5);
return S_OK;
}
@@ -803,7 +1136,6 @@ STDMETHODIMP CEVRAllocatorPresenter::ProcessMessage(MFVP_MESSAGE_TYPE eMessage, case MFVP_MESSAGE_BEGINSTREAMING : // The EVR switched from stopped to paused. The presenter should allocate resources
ResetStats();
TRACE_EVR ("MFVP_MESSAGE_BEGINSTREAMING\n");
- SetEvent(m_hEvtPresent);
break;
case MFVP_MESSAGE_CANCELSTEP : // Cancels a frame step
@@ -813,7 +1145,7 @@ STDMETHODIMP CEVRAllocatorPresenter::ProcessMessage(MFVP_MESSAGE_TYPE eMessage, case MFVP_MESSAGE_ENDOFSTREAM : // All input streams have ended.
TRACE_EVR ("MFVP_MESSAGE_ENDOFSTREAM\n");
- m_pSink->Notify (EC_COMPLETE, 0, 0);
+ m_bPendingMediaFinished = true;
break;
case MFVP_MESSAGE_ENDSTREAMING : // The EVR switched from running or paused to stopped. The presenter should free resources
@@ -822,9 +1154,9 @@ STDMETHODIMP CEVRAllocatorPresenter::ProcessMessage(MFVP_MESSAGE_TYPE eMessage, case MFVP_MESSAGE_FLUSH : // The presenter should discard any pending samples
SetEvent(m_hEvtFlush);
+ m_bEvtFlush = true;
TRACE_EVR ("MFVP_MESSAGE_FLUSH\n");
while (WaitForSingleObject(m_hEvtFlush, 1) == WAIT_OBJECT_0);
- SetEvent(m_hEvtPresent);
break;
case MFVP_MESSAGE_INVALIDATEMEDIATYPE : // The mixer's output format has changed. The EVR will initiate format negotiation, as described previously
@@ -834,11 +1166,13 @@ STDMETHODIMP CEVRAllocatorPresenter::ProcessMessage(MFVP_MESSAGE_TYPE eMessage, 3) The presenter sets the media type on the mixer's output stream.
4) The EVR sets the media type on the substreams.
*/
- RenegotiateMediaType();
+ m_bPendingRenegotiate = true;
+ while (*((volatile bool *)&m_bPendingRenegotiate))
+ Sleep(1);
break;
case MFVP_MESSAGE_PROCESSINPUTNOTIFY : // One input stream on the mixer has received a new sample
- GetImageFromMixer();
+// GetImageFromMixer();
break;
case MFVP_MESSAGE_STEP : // Requests a frame step.
@@ -865,15 +1199,18 @@ HRESULT CEVRAllocatorPresenter::IsMediaTypeSupported(IMFMediaType* pMixerType) CheckHR (pMixerType->GetUINT32 (MF_MT_INTERLACE_MODE, &nInterlaceMode));
- if ( (pAMMedia->majortype != MEDIATYPE_Video) ||
+/* if ( (pAMMedia->majortype != MEDIATYPE_Video) ||
(nInterlaceMode != MFVideoInterlace_Progressive) ||
( (pAMMedia->subtype != MEDIASUBTYPE_RGB32) && (pAMMedia->subtype != MEDIASUBTYPE_RGB24) &&
(pAMMedia->subtype != MEDIASUBTYPE_YUY2) && (pAMMedia->subtype != MEDIASUBTYPE_NV12) ) )
- hr = MF_E_INVALIDMEDIATYPE;
+ hr = MF_E_INVALIDMEDIATYPE;*/
+ if ( (pAMMedia->majortype != MEDIATYPE_Video))
+ hr = MF_E_INVALIDMEDIATYPE;
pMixerType->FreeRepresentation (FORMAT_VideoInfo2, (void*)pAMMedia);
return hr;
}
+
HRESULT CEVRAllocatorPresenter::CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType** pType)
{
HRESULT hr;
@@ -882,11 +1219,37 @@ HRESULT CEVRAllocatorPresenter::CreateProposedOutputType(IMFMediaType* pMixerTyp MFVIDEOFORMAT* VideoFormat;
CheckHR (pMixerType->GetRepresentation (FORMAT_MFVideoFormat, (void**)&pAMMedia));
+
VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
hr = pfMFCreateVideoMediaType (VideoFormat, &m_pMediaType);
- if (VideoFormat->videoInfo.FramesPerSecond.Numerator != 0)
- m_rtTimePerFrame = (20000000I64*VideoFormat->videoInfo.FramesPerSecond.Denominator)/VideoFormat->videoInfo.FramesPerSecond.Numerator;
+ if (0)
+ {
+ // This code doesn't work, use same method as VMR9 instead
+ if (VideoFormat->videoInfo.FramesPerSecond.Numerator != 0)
+ {
+ switch (VideoFormat->videoInfo.InterlaceMode)
+ {
+ case MFVideoInterlace_Progressive:
+ case MFVideoInterlace_MixedInterlaceOrProgressive:
+ default:
+ {
+ m_rtTimePerFrame = (10000000I64*VideoFormat->videoInfo.FramesPerSecond.Denominator)/VideoFormat->videoInfo.FramesPerSecond.Numerator;
+ m_bInterlaced = false;
+ }
+ break;
+ case MFVideoInterlace_FieldSingleUpper:
+ case MFVideoInterlace_FieldSingleLower:
+ case MFVideoInterlace_FieldInterleavedUpperFirst:
+ case MFVideoInterlace_FieldInterleavedLowerFirst:
+ {
+ m_rtTimePerFrame = (20000000I64*VideoFormat->videoInfo.FramesPerSecond.Denominator)/VideoFormat->videoInfo.FramesPerSecond.Numerator;
+ m_bInterlaced = true;
+ }
+ break;
+ }
+ }
+ }
m_AspectRatio.cx = VideoFormat->videoInfo.PixelAspectRatio.Numerator;
m_AspectRatio.cy = VideoFormat->videoInfo.PixelAspectRatio.Denominator;
@@ -899,12 +1262,58 @@ HRESULT CEVRAllocatorPresenter::CreateProposedOutputType(IMFMediaType* pMixerTyp m_pMediaType->SetUINT32 (MF_MT_PAN_SCAN_ENABLED, 0);
+ AppSettings& s = AfxGetAppSettings();
+
+#if 1
+ if (s.m_RenderSettings.iEVROutputRange == 1)
+ m_pMediaType->SetUINT32 (MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_16_235);
+ else
+ m_pMediaType->SetUINT32 (MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_0_255);
+
+// m_pMediaType->SetUINT32 (MF_MT_TRANSFER_FUNCTION, MFVideoTransFunc_10);
+
+#else
+
+ m_pMediaType->SetUINT32 (MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_0_255);
+ if (s.iEVROutputRange == 1)
+ m_pMediaType->SetUINT32 (MF_MT_YUV_MATRIX, MFVideoTransferMatrix_BT601);
+ else
+ m_pMediaType->SetUINT32 (MF_MT_YUV_MATRIX, MFVideoTransferMatrix_BT709);
+#endif
+
+
+ m_LastSetOutputRange = s.m_RenderSettings.iEVROutputRange;
+
i64Size.HighPart = m_AspectRatio.cx;
i64Size.LowPart = m_AspectRatio.cy;
m_pMediaType->SetUINT64 (MF_MT_PIXEL_ASPECT_RATIO, i64Size.QuadPart);
MFVideoArea Area = MakeArea (0, 0, VideoFormat->videoInfo.dwWidth, VideoFormat->videoInfo.dwHeight);
m_pMediaType->SetBlob(MF_MT_GEOMETRIC_APERTURE, (UINT8*)&Area, sizeof(MFVideoArea));
+
+ }
+
+ m_AspectRatio.cx *= VideoFormat->videoInfo.dwWidth;
+ m_AspectRatio.cy *= VideoFormat->videoInfo.dwHeight;
+
+ bool bDoneSomething = true;
+
+ while (bDoneSomething)
+ {
+ bDoneSomething = false;
+ INT MinNum = min(m_AspectRatio.cx, m_AspectRatio.cy);
+ INT i;
+ for (i = 2; i < MinNum+1; ++i)
+ {
+ if (m_AspectRatio.cx%i == 0 && m_AspectRatio.cy%i ==0)
+ break;
+ }
+ if (i != MinNum + 1)
+ {
+ m_AspectRatio.cx = m_AspectRatio.cx / i;
+ m_AspectRatio.cy = m_AspectRatio.cy / i;
+ bDoneSomething = true;
+ }
}
pMixerType->FreeRepresentation (FORMAT_MFVideoFormat, (void*)pAMMedia);
@@ -935,10 +1344,68 @@ HRESULT CEVRAllocatorPresenter::SetMediaType(IMFMediaType* pType) return hr;
}
+LONGLONG GetMediaTypeMerit(IMFMediaType *pMediaType)
+{
+ AM_MEDIA_TYPE* pAMMedia = NULL;
+ MFVIDEOFORMAT* VideoFormat;
+
+ HRESULT hr;
+ CheckHR (pMediaType->GetRepresentation (FORMAT_MFVideoFormat, (void**)&pAMMedia));
+ VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
+
+ LONGLONG Merit = 0;
+ switch (VideoFormat->surfaceInfo.Format)
+ {
+ case FCC('NV12'): Merit = 90000000; break;
+ case FCC('YV12'): Merit = 80000000; break;
+ case FCC('YUY2'): Merit = 70000000; break;
+ case FCC('UYVY'): Merit = 60000000; break;
+
+ case D3DFMT_X8R8G8B8: // Never opt for RGB
+ case D3DFMT_A8R8G8B8:
+ case D3DFMT_R8G8B8:
+ case D3DFMT_R5G6B5:
+ Merit = 0;
+ break;
+ default: Merit = 1000; break;
+ }
+
+ pMediaType->FreeRepresentation (FORMAT_MFVideoFormat, (void*)pAMMedia);
+
+ return Merit;
+}
+
+
+
+typedef struct
+{
+ const int Format;
+ const LPCTSTR Description;
+} D3DFORMAT_TYPE;
+
+extern const D3DFORMAT_TYPE D3DFormatType[];
+
+LPCTSTR FindD3DFormat(const D3DFORMAT Format);
+
+LPCTSTR GetMediaTypeFormatDesc(IMFMediaType *pMediaType)
+{
+ AM_MEDIA_TYPE* pAMMedia = NULL;
+ MFVIDEOFORMAT* VideoFormat;
+
+ HRESULT hr;
+ hr = pMediaType->GetRepresentation (FORMAT_MFVideoFormat, (void**)&pAMMedia);
+ VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
+
+ LPCTSTR Type = FindD3DFormat((D3DFORMAT)VideoFormat->surfaceInfo.Format);
+
+ pMediaType->FreeRepresentation (FORMAT_MFVideoFormat, (void*)pAMMedia);
+
+ return Type;
+}
+
HRESULT CEVRAllocatorPresenter::RenegotiateMediaType()
{
HRESULT hr = S_OK;
- BOOL fFoundMediaType = FALSE;
CComPtr<IMFMediaType> pMixerType;
CComPtr<IMFMediaType> pType;
@@ -948,9 +1415,11 @@ HRESULT CEVRAllocatorPresenter::RenegotiateMediaType() return MF_E_INVALIDREQUEST;
}
+ CInterfaceArray<IMFMediaType> ValidMixerTypes;
+
// Loop through all of the mixer's proposed output types.
DWORD iTypeIndex = 0;
- while (!fFoundMediaType && (hr != MF_E_NO_MORE_TYPES))
+ while ((hr != MF_E_NO_MORE_TYPES))
{
pMixerType = NULL;
pType = NULL;
@@ -965,27 +1434,56 @@ HRESULT CEVRAllocatorPresenter::RenegotiateMediaType() // Step 2. Check if we support this media type.
if (SUCCEEDED(hr))
- {
hr = IsMediaTypeSupported(pMixerType);
- }
- // Step 3. Adjust the mixer's type to match our requirements.
if (SUCCEEDED(hr))
- {
- hr = CreateProposedOutputType(pMixerType, &pType);
- }
-
+ hr = CreateProposedOutputType(pMixerType, &pType);
+
// Step 4. Check if the mixer will accept this media type.
if (SUCCEEDED(hr))
- {
hr = m_pMixer->SetOutputType(0, pType, MFT_SET_TYPE_TEST_ONLY);
- }
- // Step 5. Try to set the media type on ourselves.
if (SUCCEEDED(hr))
- {
- hr = SetMediaType(pType);
- }
+ {
+ LONGLONG Merit = GetMediaTypeMerit(pType);
+
+ int nTypes = ValidMixerTypes.GetCount();
+ int iInsertPos = 0;
+ for (int i = 0; i < nTypes; ++i)
+ {
+ LONGLONG ThisMerit = GetMediaTypeMerit(ValidMixerTypes[i]);
+ if (Merit > ThisMerit)
+ {
+ iInsertPos = i;
+ break;
+ }
+ else
+ iInsertPos = i+1;
+ }
+
+ ValidMixerTypes.InsertAt(iInsertPos, pType);
+ }
+ }
+
+
+ int nValidTypes = ValidMixerTypes.GetCount();
+ for (int i = 0; i < nValidTypes; ++i)
+ {
+ // Step 3. Adjust the mixer's type to match our requirements.
+ pType = ValidMixerTypes[i];
+ TRACE("Valid mixer output type: %ws\n", GetMediaTypeFormatDesc(pType));
+ }
+
+ for (int i = 0; i < nValidTypes; ++i)
+ {
+ // Step 3. Adjust the mixer's type to match our requirements.
+ pType = ValidMixerTypes[i];
+
+
+ TRACE("Trying mixer output type: %ws\n", GetMediaTypeFormatDesc(pType));
+
+ // Step 5. Try to set the media type on ourselves.
+ hr = SetMediaType(pType);
// Step 6. Set output media type on mixer.
if (SUCCEEDED(hr))
@@ -997,13 +1495,10 @@ HRESULT CEVRAllocatorPresenter::RenegotiateMediaType() {
SetMediaType(NULL);
}
+ else
+ break;
}
-
- if (SUCCEEDED(hr))
- {
- fFoundMediaType = TRUE;
- }
- }
+ }
pMixerType = NULL;
pType = NULL;
@@ -1011,18 +1506,19 @@ HRESULT CEVRAllocatorPresenter::RenegotiateMediaType() }
-HRESULT CEVRAllocatorPresenter::GetImageFromMixer()
+bool CEVRAllocatorPresenter::GetImageFromMixer()
{
MFT_OUTPUT_DATA_BUFFER Buffer;
HRESULT hr = S_OK;
DWORD dwStatus;
REFERENCE_TIME nsSampleTime;
- MFTIME nsCurrentTime;
LONGLONG llClockBefore = 0;
LONGLONG llClockAfter = 0;
LONGLONG llMixerLatency;
UINT dwSurface;
+ bool bDoneSomething = false;
+
while (SUCCEEDED(hr))
{
CComPtr<IMFSample> pSample;
@@ -1037,9 +1533,9 @@ HRESULT CEVRAllocatorPresenter::GetImageFromMixer() Buffer.pSample = pSample;
pSample->GetUINT32 (GUID_SURFACE_INDEX, &dwSurface);
- if (m_pClock) m_pClock->GetCorrelatedTime(0, &llClockBefore, &nsCurrentTime);
+ llClockBefore = AfxGetMyApp()->GetPerfCounter();
hr = m_pMixer->ProcessOutput (0 , 1, &Buffer, &dwStatus);
- if (m_pClock) m_pClock->GetCorrelatedTime(0, &llClockAfter, &nsCurrentTime);
+ llClockAfter = AfxGetMyApp()->GetPerfCounter();
if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT)
{
@@ -1049,21 +1545,21 @@ HRESULT CEVRAllocatorPresenter::GetImageFromMixer() if (m_pSink)
{
- CAutoLock autolock(this);
+ //CAutoLock autolock(this); We shouldn't need to lock here, m_pSink is thread safe
llMixerLatency = llClockAfter - llClockBefore;
m_pSink->Notify (EC_PROCESSING_LATENCY, (LONG_PTR)&llMixerLatency, 0);
}
pSample->GetSampleTime (&nsSampleTime);
+ REFERENCE_TIME nsDuration;
+ pSample->GetSampleDuration (&nsDuration);
// Update internal subtitle clock
if(m_fUseInternalTimer && m_pSubPicQueue)
{
- MFTIME nsDuration;
- float m_fps;
- pSample->GetSampleDuration(&nsDuration);
m_fps = (float)(10000000.0 / nsDuration);
- m_pSubPicQueue->SetFPS(m_fps);
+// m_fps = 10000000.0 / (double)(m_rtTimePerFrame);
+ m_pSubPicQueue->SetFPS(23.976);
}
if (AfxGetMyApp()->m_fTearingTest)
@@ -1082,14 +1578,16 @@ HRESULT CEVRAllocatorPresenter::GetImageFromMixer() m_nTearingPos = (m_nTearingPos + 7) % m_NativeVideoSize.cx;
}
- TRACE_EVR ("Get from Mixer : %d (%I64d)\n", dwSurface, nsSampleTime);
+ LONGLONG TimePerFrame = m_rtTimePerFrame;
+ TRACE_EVR ("Get from Mixer : %d (%I64d) (%I64d)\n", dwSurface, nsSampleTime, nsSampleTime/TimePerFrame);
- MoveToScheduledList (pSample);
- ReleaseSemaphore (m_hSemPicture, 1, NULL);
- InterlockedIncrement (&m_nUsedBuffer);
+ MoveToScheduledList (pSample, false);
+ bDoneSomething = true;
+ if (m_rtTimePerFrame == 0)
+ break;
}
- return hr;
+ return bDoneSomething;
}
@@ -1128,6 +1626,7 @@ STDMETHODIMP CEVRAllocatorPresenter::InitServicePointers(/* [in] */ __in IMFTop hr = pLookup->LookupService (MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_RENDER_SERVICE,
__uuidof (IMFClock ), (void**)&m_pClock, &dwObjects);
+
StartWorkerThreads();
return S_OK;
}
@@ -1392,7 +1891,11 @@ STDMETHODIMP CEVRAllocatorPresenter::GetNativeVideoSize(LONG* lpWidth, LONG* lpH STDMETHODIMP CEVRAllocatorPresenter::InitializeDevice(AM_MEDIA_TYPE* pMediaType)
{
HRESULT hr;
+ CAutoLock lock(this);
+ CAutoLock lock2(&m_ImageProcessingLock);
+ CAutoLock cRenderLock(&m_RenderLock);
+ RemoveAllSamples();
DeleteSurfaces();
VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*) pMediaType->pbFormat;
@@ -1400,10 +1903,12 @@ STDMETHODIMP CEVRAllocatorPresenter::InitializeDevice(AM_MEDIA_TYPE* pMediaType) int h = abs(vih2->bmiHeader.biHeight);
m_NativeVideoSize = CSize(w, h);
- hr = AllocSurfaces(D3DFMT_X8R8G8B8);
+ if (m_bHighColorResolution)
+ hr = AllocSurfaces(D3DFMT_A2R10G10B10);
+ else
+ hr = AllocSurfaces(D3DFMT_X8R8G8B8);
+
- CAutoLock lock(this);
- RemoveAllSamples();
for(int i = 0; i < m_nNbDXSurface; i++)
{
CComPtr<IMFSample> pMFSample;
@@ -1422,6 +1927,13 @@ STDMETHODIMP CEVRAllocatorPresenter::InitializeDevice(AM_MEDIA_TYPE* pMediaType) }
+DWORD WINAPI CEVRAllocatorPresenter::GetMixerThreadStatic(LPVOID lpParam)
+{
+ CEVRAllocatorPresenter* pThis = (CEVRAllocatorPresenter*) lpParam;
+ pThis->GetMixerThread();
+ return 0;
+}
+
DWORD WINAPI CEVRAllocatorPresenter::PresentThread(LPVOID lpParam)
{
@@ -1436,29 +1948,353 @@ void CEVRAllocatorPresenter::CheckWaitingSampleFromMixer() if (m_bWaitingSample)
{
m_bWaitingSample = false;
- GetImageFromMixer();
+ //GetImageFromMixer(); // Do this in processing thread instead
+ }
+}
+
+
+bool ExtractInterlaced(const AM_MEDIA_TYPE* pmt)
+{
+ if (pmt->formattype==FORMAT_VideoInfo)
+ return false;
+ else if (pmt->formattype==FORMAT_VideoInfo2)
+ return (((VIDEOINFOHEADER2*)pmt->pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
+ else if (pmt->formattype==FORMAT_MPEGVideo)
+ return false;
+ else if (pmt->formattype==FORMAT_MPEG2Video)
+ return (((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr.dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
+ else
+ return false;
+}
+
+
+void CEVRAllocatorPresenter::GetMixerThread()
+{
+ HANDLE hAvrt;
+ HANDLE hEvts[] = { m_hEvtQuit};
+ bool bQuit = false;
+ TIMECAPS tc;
+ DWORD dwResolution;
+ DWORD dwUser = 0;
+ DWORD dwTaskIndex = 0;
+
+ // Tell Vista Multimedia Class Scheduler we are a playback thretad (increase priority)
+// if (pfAvSetMmThreadCharacteristicsW)
+// hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
+// if (pfAvSetMmThreadPriority)
+// pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/);
+
+ timeGetDevCaps(&tc, sizeof(TIMECAPS));
+ dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
+ dwUser = timeBeginPeriod(dwResolution);
+
+ while (!bQuit)
+ {
+ DWORD dwObject = WaitForMultipleObjects (countof(hEvts), hEvts, FALSE, 1);
+ switch (dwObject)
+ {
+ case WAIT_OBJECT_0 :
+ bQuit = true;
+ break;
+ case WAIT_TIMEOUT :
+ {
+ bool bDoneSomething = false;
+ {
+ CAutoLock AutoLock(&m_ImageProcessingLock);
+ bDoneSomething = GetImageFromMixer();
+ }
+ if (m_rtTimePerFrame == 0 && bDoneSomething)
+ {
+ //CAutoLock lock(this);
+ //CAutoLock lock2(&m_ImageProcessingLock);
+ //CAutoLock cRenderLock(&m_RenderLock);
+
+ // Use the code from VMR9 to get the movie fps, as this method is reliable.
+ CComPtr<IPin> pPin;
+ CMediaType mt;
+ if (
+ SUCCEEDED (m_pOuterEVR->FindPin(L"EVR Input0", &pPin)) &&
+ SUCCEEDED (pPin->ConnectionMediaType(&mt)) )
+ {
+ ExtractAvgTimePerFrame (&mt, m_rtTimePerFrame);
+
+ m_bInterlaced = ExtractInterlaced(&mt);
+
+ }
+ // If framerate not set by Video Decoder choose 23.97...
+ if (m_rtTimePerFrame == 0)
+ m_rtTimePerFrame = 417166;
+ }
+
+ }
+ break;
+ }
}
+
+ timeEndPeriod (dwResolution);
+// if (pfAvRevertMmThreadCharacteristics) pfAvRevertMmThreadCharacteristics (hAvrt);
}
+void ModerateFloat(double& Value, double Target, double& ValuePrim, double ChangeSpeed)
+{
+ double xbiss = (-(ChangeSpeed)*(ValuePrim) - (Value-Target)*(ChangeSpeed*ChangeSpeed)*0.25f);
+ ValuePrim += xbiss;
+ Value += ValuePrim;
+}
+
+LONGLONG CEVRAllocatorPresenter::GetClockTime(LONGLONG PerformanceCounter)
+{
+ LONGLONG llClockTime;
+ MFTIME nsCurrentTime;
+ m_pClock->GetCorrelatedTime(0, &llClockTime, &nsCurrentTime);
+ DWORD Characteristics = 0;
+ m_pClock->GetClockCharacteristics(&Characteristics);
+ MFCLOCK_STATE State;
+ m_pClock->GetState(0, &State);
+
+ if (!(Characteristics & MFCLOCK_CHARACTERISTICS_FLAG_FREQUENCY_10MHZ))
+ {
+ MFCLOCK_PROPERTIES Props;
+ if (m_pClock->GetProperties(&Props) == S_OK)
+ llClockTime = (llClockTime * 10000000) / Props.qwClockFrequency; // Make 10 MHz
+
+ }
+ LONGLONG llPerf = PerformanceCounter;
+// return llClockTime + (llPerf - nsCurrentTime);
+ double Target = llClockTime + (llPerf - nsCurrentTime) * m_ModeratedTimeSpeed;
+
+ bool bReset = false;
+ if (m_ModeratedTimeLast < 0 || State != m_LastClockState || m_ModeratedClockLast < 0)
+ {
+ bReset = true;
+ m_ModeratedTimeLast = llPerf;
+ m_ModeratedClockLast = llClockTime;
+ }
+
+ m_LastClockState = State;
+
+ double TimeChange = llPerf - m_ModeratedTimeLast;
+ double ClockChange = llClockTime - m_ModeratedClockLast;
+
+ m_ModeratedTimeLast = llPerf;
+ m_ModeratedClockLast = llClockTime;
+
+#if 1
+
+ if (bReset)
+ {
+ m_ModeratedTimeSpeed = 1.0;
+ m_ModeratedTimeSpeedPrim = 0.0;
+ ZeroMemory(m_TimeChangeHisotry, sizeof(m_TimeChangeHisotry));
+ ZeroMemory(m_ClockChangeHisotry, sizeof(m_ClockChangeHisotry));
+ m_ClockTimeChangeHistoryPos = 0;
+ }
+ if (TimeChange)
+ {
+ int Pos = m_ClockTimeChangeHistoryPos % 100;
+ int nHistory = min(m_ClockTimeChangeHistoryPos, 100);
+ ++m_ClockTimeChangeHistoryPos;
+ if (nHistory > 50)
+ {
+ int iLastPos = (Pos - (nHistory)) % 100;
+ if (iLastPos < 0)
+ iLastPos += 100;
+
+ double TimeChange = llPerf - m_TimeChangeHisotry[iLastPos];
+ double ClockChange = llClockTime - m_ClockChangeHisotry[iLastPos];
+
+ double ClockSpeedTarget = ClockChange / TimeChange;
+ double ChangeSpeed = 0.1;
+ if (ClockSpeedTarget > m_ModeratedTimeSpeed)
+ {
+ if (ClockSpeedTarget / m_ModeratedTimeSpeed > 0.1)
+ ChangeSpeed = 0.1;
+ else
+ ChangeSpeed = 0.01;
+ }
+ else
+ {
+ if (m_ModeratedTimeSpeed / ClockSpeedTarget > 0.1)
+ ChangeSpeed = 0.1;
+ else
+ ChangeSpeed = 0.01;
+ }
+ ModerateFloat(m_ModeratedTimeSpeed, ClockSpeedTarget, m_ModeratedTimeSpeedPrim, ChangeSpeed);
+// m_ModeratedTimeSpeed = TimeChange / ClockChange;
+ }
+ m_TimeChangeHisotry[Pos] = llPerf;
+ m_ClockChangeHisotry[Pos] = llClockTime;
+ }
+
+ return Target;
+#else
+ double EstimateTime = m_ModeratedTime + TimeChange * m_ModeratedTimeSpeed + m_ClockDiffCalc;
+ double Diff = Target - EstimateTime;
+
+ // > 5 ms just set it
+ if ((fabs(Diff) > 50000.0 || bReset))
+ {
+
+// TRACE("Reset clock at diff: %f ms\n", (m_ModeratedTime - Target) /10000.0);
+ if (State == MFCLOCK_STATE_RUNNING)
+ {
+ if (bReset)
+ {
+ m_ModeratedTimeSpeed = 1.0;
+ m_ModeratedTimeSpeedPrim = 0.0;
+ m_ClockDiffCalc = 0;
+ m_ClockDiffPrim = 0;
+ m_ModeratedTime = Target;
+ m_ModeratedTimer = llPerf;
+ }
+ else
+ {
+ EstimateTime = m_ModeratedTime + TimeChange * m_ModeratedTimeSpeed;
+ Diff = Target - EstimateTime;
+ m_ClockDiffCalc = Diff;
+ m_ClockDiffPrim = 0;
+ }
+ }
+ else
+ {
+ m_ModeratedTimeSpeed = 0.0;
+ m_ModeratedTimeSpeedPrim = 0.0;
+ m_ClockDiffCalc = 0;
+ m_ClockDiffPrim = 0;
+ m_ModeratedTime = Target;
+ m_ModeratedTimer = llPerf;
+ }
+ }
+
+ {
+ LONGLONG ModerateTime = 10000;
+ double ChangeSpeed = 1.00;
+/* if (m_ModeratedTimeSpeedPrim != 0.0)
+ {
+ if (m_ModeratedTimeSpeedPrim < 0.1)
+ ChangeSpeed = 0.1;
+ }*/
+
+ int nModerate = 0;
+ double Change = 0;
+ while (m_ModeratedTimer < llPerf - ModerateTime)
+ {
+ m_ModeratedTimer += ModerateTime;
+ m_ModeratedTime += double(ModerateTime) * m_ModeratedTimeSpeed;
+
+ double TimerDiff = llPerf - m_ModeratedTimer;
+
+ double Diff = (double)(m_ModeratedTime - (Target - TimerDiff));
+
+ double TimeSpeedTarget;
+ double AbsDiff = fabs(Diff);
+ TimeSpeedTarget = 1.0 - (Diff / 1000000.0);
+// TimeSpeedTarget = m_ModeratedTimeSpeed - (Diff / 100000000000.0);
+ //if (AbsDiff > 20000.0)
+// TimeSpeedTarget = 1.0 - (Diff / 1000000.0);
+ /*else if (AbsDiff > 5000.0)
+ TimeSpeedTarget = 1.0 - (Diff / 100000000.0);
+ else
+ TimeSpeedTarget = 1.0 - (Diff / 500000000.0);*/
+ double StartMod = m_ModeratedTimeSpeed;
+ ModerateFloat(m_ModeratedTimeSpeed, TimeSpeedTarget, m_ModeratedTimeSpeedPrim, ChangeSpeed);
+ m_ModeratedTimeSpeed = TimeSpeedTarget;
+ ++nModerate;
+ Change += m_ModeratedTimeSpeed - StartMod;
+ }
+ if (nModerate)
+ m_ModeratedTimeSpeedDiff = Change / nModerate;
+
+ double Ret = m_ModeratedTime + double(llPerf - m_ModeratedTimer) * m_ModeratedTimeSpeed;
+ double Diff = Target - Ret;
+ ModerateFloat(m_ClockDiffCalc, Diff, m_ClockDiffPrim, ChangeSpeed*0.1);
+
+ Ret += m_ClockDiffCalc;
+ Diff = Target - Ret;
+ m_ClockDiff = Diff;
+ return LONGLONG(Ret + 0.5);
+ }
+
+ return Target;
+ return LONGLONG(m_ModeratedTime + 0.5);
+#endif
+}
+
+void CEVRAllocatorPresenter::OnVBlankFinished(bool fAll, LONGLONG PerformanceCounter)
+{
+ if (!m_pCurrentDisplaydSample || !m_OrderedPaint || !fAll)
+ return;
+
+ LONGLONG llClockTime;
+ LONGLONG nsSampleTime;
+ LONGLONG SampleDuration = 0;
+ if (!m_bSignaledStarvation)
+ {
+ llClockTime = GetClockTime(PerformanceCounter);
+ m_StarvationClock = llClockTime;
+ }
+ else
+ {
+ llClockTime = m_StarvationClock;
+ }
+ m_pCurrentDisplaydSample->GetSampleDuration(&SampleDuration);
+
+ m_pCurrentDisplaydSample->GetSampleTime(&nsSampleTime);
+ LONGLONG TimePerFrame = m_rtTimePerFrame;
+ if (!TimePerFrame)
+ return;
+ if (SampleDuration > 1)
+ TimePerFrame = SampleDuration;
+
+ {
+ m_nNextSyncOffset = (m_nNextSyncOffset+1) % NB_JITTER;
+ LONGLONG SyncOffset = nsSampleTime - llClockTime;
+
+ m_pllSyncOffset[m_nNextSyncOffset] = SyncOffset;
+// TRACE("SyncOffset(%d, %d): %8I64d %8I64d %8I64d \n", m_nCurSurface, m_VSyncMode, m_LastPredictedSync, -SyncOffset, m_LastPredictedSync - (-SyncOffset));
+
+ m_MaxSyncOffset = MINLONG64;
+ m_MinSyncOffset = MAXLONG64;
+
+ LONGLONG AvrageSum = 0;
+ for (int i=0; i<NB_JITTER; i++)
+ {
+ LONGLONG Offset = m_pllSyncOffset[i];
+ AvrageSum += Offset;
+ m_MaxSyncOffset = max(m_MaxSyncOffset, Offset);
+ m_MinSyncOffset = min(m_MinSyncOffset, Offset);
+ }
+ double MeanOffset = double(AvrageSum)/NB_JITTER;
+ double DeviationSum = 0;
+ for (int i=0; i<NB_JITTER; i++)
+ {
+ double Deviation = double(m_pllSyncOffset[i]) - MeanOffset;
+ DeviationSum += Deviation*Deviation;
+ }
+ double StdDev = sqrt(DeviationSum/NB_JITTER);
+
+ m_fSyncOffsetAvr = MeanOffset;
+ m_bSyncStatsAvailable = true;
+ m_fSyncOffsetStdDev = StdDev;
+
+
+ }
+}
void CEVRAllocatorPresenter::RenderThread()
{
HANDLE hAvrt;
DWORD dwTaskIndex = 0;
- HANDLE hEvts[] = { m_hEvtQuit, m_hEvtFlush, m_hEvtPresent, m_hEvtFrameTimer};
- HANDLE hEvtsBuff[] = { m_hEvtQuit, m_hEvtFlush, m_hSemPicture };
+ HANDLE hEvts[] = { m_hEvtQuit, m_hEvtFlush};
bool bQuit = false;
TIMECAPS tc;
DWORD dwResolution;
MFTIME nsSampleTime;
- MFTIME nsCurrentTime;
LONGLONG llClockTime;
- long lDelay;
DWORD dwUser = 0;
DWORD dwObject;
- UINT nNbPlayingFrame = 0;
-
+
// Tell Vista Multimedia Class Scheduler we are a playback thretad (increase priority)
if (pfAvSetMmThreadCharacteristicsW) hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
if (pfAvSetMmThreadPriority) pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/);
@@ -1466,11 +2302,26 @@ void CEVRAllocatorPresenter::RenderThread() timeGetDevCaps(&tc, sizeof(TIMECAPS));
dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
dwUser = timeBeginPeriod(dwResolution);
+ AppSettings& s = AfxGetAppSettings();
-
+ int NextSleepTime = 1;
while (!bQuit)
{
- dwObject = WaitForMultipleObjects (countof(hEvts), hEvts, FALSE, INFINITE);
+ LONGLONG llPerf = AfxGetMyApp()->GetPerfCounter();
+ if (!s.m_RenderSettings.iVMR9VSyncAccurate && NextSleepTime == 0)
+ NextSleepTime = 1;
+ dwObject = WaitForMultipleObjects (countof(hEvts), hEvts, FALSE, max(NextSleepTime < 0 ? 1 : NextSleepTime, 0));
+/* dwObject = WAIT_TIMEOUT;
+ if (m_bEvtFlush)
+ dwObject = WAIT_OBJECT_0 + 1;
+ else if (m_bEvtQuit)
+ dwObject = WAIT_OBJECT_0;*/
+// if (NextSleepTime)
+// TRACE("Sleep: %7.3f\n", double(AfxGetMyApp()->GetPerfCounter()-llPerf) / 10000.0);
+ if (NextSleepTime > 1)
+ NextSleepTime = 0;
+ else if (NextSleepTime == 0)
+ NextSleepTime = -1;
switch (dwObject)
{
case WAIT_OBJECT_0 :
@@ -1478,72 +2329,332 @@ void CEVRAllocatorPresenter::RenderThread() break;
case WAIT_OBJECT_0 + 1 :
// Flush pending samples!
- if (dwUser != -1) timeKillEvent (dwUser);
- dwUser = -1;
-
FlushSamples();
+ m_bEvtFlush = false;
ResetEvent(m_hEvtFlush);
TRACE_EVR ("Flush done!\n");
break;
- case WAIT_OBJECT_0 + 2 :
- case WAIT_OBJECT_0 + 3 :
+ case WAIT_TIMEOUT :
+
+ if (m_LastSetOutputRange != -1 && m_LastSetOutputRange != s.m_RenderSettings.iEVROutputRange || m_bPendingRenegotiate)
+ {
+ FlushSamples();
+ RenegotiateMediaType();
+ m_bPendingRenegotiate = false;
+ }
+ if (m_bPendingResetDevice)
+ {
+ m_bPendingResetDevice = false;
+ CAutoLock lock(this);
+ CAutoLock lock2(&m_ImageProcessingLock);
+ CAutoLock cRenderLock(&m_RenderLock);
+
+
+ RemoveAllSamples();
+
+ CDX9AllocatorPresenter::ResetDevice();
+
+ for(int i = 0; i < m_nNbDXSurface; i++)
+ {
+ CComPtr<IMFSample> pMFSample;
+ HRESULT hr = pfMFCreateVideoSampleFromSurface (m_pVideoSurface[i], &pMFSample);
+
+ if (SUCCEEDED (hr))
+ {
+ pMFSample->SetUINT32 (GUID_SURFACE_INDEX, i);
+ m_FreeSamples.AddTail (pMFSample);
+ }
+ ASSERT (SUCCEEDED (hr));
+ }
+
+ }
// Discard timer events if playback stop
- if ((dwObject == WAIT_OBJECT_0 + 3) && (m_nRenderState != Started)) continue;
+// if ((dwObject == WAIT_OBJECT_0 + 3) && (m_nRenderState != Started)) continue;
// TRACE_EVR ("RenderThread ==>> Waiting buffer\n");
- if (WaitForMultipleObjects (countof(hEvtsBuff), hEvtsBuff, FALSE, INFINITE) == WAIT_OBJECT_0+2)
+// if (WaitForMultipleObjects (countof(hEvtsBuff), hEvtsBuff, FALSE, INFINITE) == WAIT_OBJECT_0+2)
{
CComPtr<IMFSample> pMFSample;
- if (SUCCEEDED (GetScheduledSample(&pMFSample)))
- {
- pMFSample->GetUINT32 (GUID_SURFACE_INDEX, (UINT32*)&m_nCurSurface);
- pMFSample->GetSampleTime (&nsSampleTime);
+ LONGLONG llPerf = AfxGetMyApp()->GetPerfCounter();
+ int nSamplesLeft = 0;
+ if (SUCCEEDED (GetScheduledSample(&pMFSample, nSamplesLeft)))
+ {
+// pMFSample->GetUINT32 (GUID_SURFACE_INDEX, (UINT32*)&m_nCurSurface);
+ m_pCurrentDisplaydSample = pMFSample;
- TRACE_EVR ("RenderThread ==>> Presenting surface %d (%I64d)\n", m_nCurSurface, nsSampleTime);
+ bool bValidSampleTime = true;
+ if (pMFSample->GetSampleTime (&nsSampleTime) != S_OK || nsSampleTime == 0)
+ bValidSampleTime = false;
+ // We assume that all samples have the same duration
+ LONGLONG SampleDuration = 0;
+ pMFSample->GetSampleDuration(&SampleDuration);
- __super::SetTime (g_tSegmentStart + nsSampleTime);
- Paint(true);
+// TRACE_EVR ("RenderThread ==>> Presenting surface %d (%I64d)\n", m_nCurSurface, nsSampleTime);
- m_pcFramesDrawn++;
- InterlockedDecrement (&m_nUsedBuffer);
- CompleteFrameStep (false);
+ bool bStepForward = false;
- if ((m_nRenderState == Started) && (m_nStepCount == 0))
+ if (m_nStepCount < 0)
+ {
+ // Drop frame
+ TRACE_EVR ("Dropped frame\n");
+ m_pcFrames++;
+ bStepForward = true;
+ m_nStepCount = 0;
+ }
+ else if (m_nStepCount > 0)
+ {
+ pMFSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32 *)&m_nCurSurface);
+ ++m_OrderedPaint;
+ __super::SetTime (g_tSegmentStart + nsSampleTime);
+ Paint(true);
+ m_nDroppedUpdate = 0;
+ CompleteFrameStep (false);
+ bStepForward = true;
+ }
+ else if ((m_nRenderState == Started))
{
// Calculate wake up timer
- m_pClock->GetCorrelatedTime(0, &llClockTime, &nsCurrentTime);
-
- //if (m_rtTimePerFrame == 0) CalculateFrameRate(/*nsSampleTime*/);
- // Wakup 1/2 refresh rate before next VSync!
- lDelay = (UINT)((nsSampleTime + m_rtTimePerFrame - llClockTime) / 10000) - (500/m_RefreshRate);
-
- if (lDelay > 0)
+ LONGLONG CurrentCounter = AfxGetMyApp()->GetPerfCounter();
+ if (!m_bSignaledStarvation)
+ {
+ llClockTime = GetClockTime(CurrentCounter);
+ m_StarvationClock = llClockTime;
+ }
+ else
{
- // TRACE_EVR ("RenderThread ==>> Set timer %d %I64d Cons=%d \n", lDelay, nsSampleTime, m_nCurSurface);
- dwUser = timeSetEvent (lDelay, dwResolution, (LPTIMECALLBACK)m_hEvtFrameTimer, NULL, TIME_CALLBACK_EVENT_SET);
+ llClockTime = m_StarvationClock;
+ }
- // Update statistics
- nNbPlayingFrame++;
+ if (!bValidSampleTime)
+ {
+ // Just play as fast as possible
+ bStepForward = true;
+ pMFSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32 *)&m_nCurSurface);
+ ++m_OrderedPaint;
+ __super::SetTime (g_tSegmentStart + nsSampleTime);
+ Paint(true);
}
else
{
- dwUser = -1;
- if (m_nRenderState == Started) m_pcFrames++;
- // TRACE_EVR ("RenderThread ==>> immediate display %I64d (delay=%d) Cons=%d\n", nsSampleTime/417188, lDelay, m_nCurSurface);
- SetEvent (m_hEvtPresent);
+ LONGLONG TimePerFrame = GetFrameTime() * 10000000.0;
+ LONGLONG DrawTime = (m_PaintTime) * 0.9 - 20000.0; // 2 ms offset
+ //if (!s.iVMR9VSync)
+ DrawTime = 0;
+
+ LONGLONG SyncOffset = 0;
+ LONGLONG VSyncTime = 0;
+ LONGLONG RefreshTime = 0;
+ LONGLONG TimeToNextVSync = -1;
+ bool bVSyncCorrection = false;
+ double DetectedRefreshTime;
+ double DetectedScanlinesPerFrame;
+ double DetectedScanlineTime;
+ int DetectedRefreshRatePos;
+ {
+ CAutoLock Lock(&m_RefreshRateLock);
+ DetectedRefreshTime = m_DetectedRefreshTime;
+ DetectedRefreshRatePos = m_DetectedRefreshRatePos;
+ DetectedScanlinesPerFrame = m_DetectedScanlinesPerFrame;
+ DetectedScanlineTime = m_DetectedScanlineTime;
+ }
+
+ if (s.m_RenderSettings.iVMR9VSync && DetectedRefreshTime && DetectedRefreshRatePos > 20)
+ {
+ bVSyncCorrection = true;
+ double TargetVSyncPos = GetVBlackPos();
+ double RefreshLines = DetectedScanlinesPerFrame;
+ double RefreshTime = DetectedRefreshTime;
+ double ScanlinesPerSecond = 1.0/DetectedScanlineTime;
+ double CurrentVSyncPos = fmod(double(m_VBlankStartMeasure) + ScanlinesPerSecond * ((CurrentCounter - m_VBlankStartMeasureTime) / 10000000.0), RefreshLines);
+ double LinesUntilVSync = 0;
+ //TargetVSyncPos -= ScanlinesPerSecond * (DrawTime/10000000.0);
+ //TargetVSyncPos -= 10;
+ TargetVSyncPos = fmod(TargetVSyncPos, RefreshLines);
+ if (TargetVSyncPos < 0)
+ TargetVSyncPos += RefreshLines;
+ if (TargetVSyncPos > CurrentVSyncPos)
+ LinesUntilVSync = TargetVSyncPos - CurrentVSyncPos;
+ else
+ LinesUntilVSync = (RefreshLines - CurrentVSyncPos) + TargetVSyncPos;
+ double TimeUntilVSync = LinesUntilVSync * DetectedScanlineTime;
+ TimeToNextVSync = TimeUntilVSync * 10000000.0;
+ VSyncTime = DetectedRefreshTime * 10000000.0;
+ RefreshTime = VSyncTime;
+
+ LONGLONG ClockTimeAtNextVSync = llClockTime + (TimeUntilVSync * 10000000.0) * m_ModeratedTimeSpeed;
+
+ SyncOffset = (nsSampleTime - ClockTimeAtNextVSync);
+
+// if (SyncOffset < 0)
+// TRACE("SyncOffset(%d): %I64d %I64d %I64d\n", m_nCurSurface, SyncOffset, TimePerFrame, VSyncTime);
+ }
+ else
+ SyncOffset = (nsSampleTime - llClockTime);
+
+ //LONGLONG SyncOffset = nsSampleTime - llClockTime;
+ TRACE_EVR ("SyncOffset: %I64d SampleFrame: %I64d ClockFrame: %I64d\n", SyncOffset, nsSampleTime/TimePerFrame, llClockTime /TimePerFrame);
+ if (SampleDuration > 1 && !m_DetectedLock)
+ TimePerFrame = SampleDuration;
+
+ LONGLONG MinMargin;
+ if (m_FrameTimeCorrection && 0)
+ MinMargin = 15000.0;
+ else
+ MinMargin = 15000.0 + min(m_DetectedFrameTimeStdDev, 20000.0);
+ LONGLONG TimePerFrameMargin = min(double(TimePerFrame)*0.11, max(double(TimePerFrame)*0.02, MinMargin));
+ LONGLONG TimePerFrameMargin0 = TimePerFrameMargin/2;
+ LONGLONG TimePerFrameMargin1 = 0;
+
+ if (m_DetectedLock && TimePerFrame < VSyncTime)
+ VSyncTime = TimePerFrame;
+
+ if (m_VSyncMode == 1)
+ TimePerFrameMargin1 = -TimePerFrameMargin;
+ else if (m_VSyncMode == 2)
+ TimePerFrameMargin1 = TimePerFrameMargin;
+
+ m_LastSampleOffset = SyncOffset;
+ m_bLastSampleOffsetValid = true;
+
+ LONGLONG VSyncOffset0 = 0;
+ bool bDoVSyncCorrection = false;
+ if ((SyncOffset < -(TimePerFrame + TimePerFrameMargin0 - TimePerFrameMargin1)) && nSamplesLeft > 0) // Only drop if we have something else to display at once
+ {
+ // Drop frame
+ TRACE_EVR ("Dropped frame\n");
+ m_pcFrames++;
+ bStepForward = true;
+ ++m_nDroppedUpdate;
+ NextSleepTime = 0;
+// VSyncOffset0 = (-SyncOffset) - VSyncTime;
+ //VSyncOffset0 = (-SyncOffset) - VSyncTime + TimePerFrameMargin1;
+ //m_LastPredictedSync = VSyncOffset0;
+ bDoVSyncCorrection = false;
+ }
+ else if (SyncOffset < TimePerFrameMargin1)
+ {
+
+ if (bVSyncCorrection)
+ {
+// VSyncOffset0 = -SyncOffset;
+ VSyncOffset0 = -SyncOffset;
+ bDoVSyncCorrection = true;
+ }
+
+ // Paint and prepare for next frame
+ TRACE_EVR ("Normalframe\n");
+ m_nDroppedUpdate = 0;
+ bStepForward = true;
+ pMFSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32 *)&m_nCurSurface);
+ m_LastFrameDuration = nsSampleTime - m_LastSampleTime;
+ m_LastSampleTime = nsSampleTime;
+ m_LastPredictedSync = VSyncOffset0;
+
+ ++m_OrderedPaint;
+ __super::SetTime (g_tSegmentStart + nsSampleTime);
+ Paint(true);
+ //m_pSink->Notify(EC_SCRUB_TIME, LODWORD(nsSampleTime), HIDWORD(nsSampleTime));
+
+ NextSleepTime = 0;
+ m_pcFramesDrawn++;
+ }
+ else
+ {
+ if (TimeToNextVSync >= 0 && SyncOffset > 0)
+ {
+ NextSleepTime = ((TimeToNextVSync)/10000) - 2;
+ }
+ else
+ NextSleepTime = ((SyncOffset)/10000) - 2;
+
+ if (NextSleepTime > TimePerFrame)
+ NextSleepTime = 1;
+
+ if (NextSleepTime < 0)
+ NextSleepTime = 0;
+ NextSleepTime = 1;
+ //TRACE_EVR ("Delay\n");
+ }
+
+ if (bDoVSyncCorrection)
+ {
+ //LONGLONG VSyncOffset0 = (((SyncOffset) % VSyncTime) + VSyncTime) % VSyncTime;
+ LONGLONG Margin = TimePerFrameMargin;
+
+ LONGLONG VSyncOffsetMin = 30000000000000;
+ LONGLONG VSyncOffsetMax = -30000000000000;
+ for (int i = 0; i < 5; ++i)
+ {
+ VSyncOffsetMin = min(m_VSyncOffsetHistory[i], VSyncOffsetMin);
+ VSyncOffsetMax = max(m_VSyncOffsetHistory[i], VSyncOffsetMax);
+ }
+
+ m_VSyncOffsetHistory[m_VSyncOffsetHistoryPos] = VSyncOffset0;
+ m_VSyncOffsetHistoryPos = (m_VSyncOffsetHistoryPos + 1) % 5;
+
+// LONGLONG VSyncTime2 = VSyncTime2 + (VSyncOffsetMax - VSyncOffsetMin);
+ //VSyncOffsetMin; = (((VSyncOffsetMin) % VSyncTime) + VSyncTime) % VSyncTime;
+ //VSyncOffsetMax = (((VSyncOffsetMax) % VSyncTime) + VSyncTime) % VSyncTime;
+
+// TRACE("SyncOffset(%d, %d): %8I64d %8I64d %8I64d %8I64d\n", m_nCurSurface, m_VSyncMode,VSyncOffset0, VSyncOffsetMin, VSyncOffsetMax, VSyncOffsetMax - VSyncOffsetMin);
+
+ if (m_VSyncMode == 0)
+ {
+ // 23.976 in 60 Hz
+ if (VSyncOffset0 < Margin && VSyncOffsetMax > (VSyncTime - Margin))
+ {
+ m_VSyncMode = 2;
+ }
+ else if (VSyncOffset0 > (VSyncTime - Margin) && VSyncOffsetMin < Margin)
+ {
+ m_VSyncMode = 1;
+ }
+ }
+ else if (m_VSyncMode == 2)
+ {
+ if (VSyncOffsetMin > (Margin))
+ {
+ m_VSyncMode = 0;
+ }
+ }
+ else if (m_VSyncMode == 1)
+ {
+ if (VSyncOffsetMax < (VSyncTime - Margin))
+ {
+ m_VSyncMode = 0;
+ }
+ }
+ }
+
}
}
- MoveToFreeList(pMFSample, true);
- CheckWaitingSampleFromMixer();
+ m_pCurrentDisplaydSample = NULL;
+ if (bStepForward)
+ {
+ MoveToFreeList(pMFSample, true);
+ CheckWaitingSampleFromMixer();
+ m_MaxSampleDuration = max(SampleDuration, m_MaxSampleDuration);
+ }
+ else
+ MoveToScheduledList(pMFSample, true);
}
+ else if (m_bLastSampleOffsetValid && m_LastSampleOffset < -10000000) // Only starve if we are 1 seconds behind
+ {
+ if (m_nRenderState == Started)
+ {
+ m_pSink->Notify(EC_STARVATION, 0, 0);
+ m_bSignaledStarvation = true;
+ }
+ }
+ //GetImageFromMixer();
}
- else
- {
- TRACE_EVR ("RenderThread ==>> Flush before rendering frame!\n");
- }
+// else
+// {
+// TRACE_EVR ("RenderThread ==>> Flush before rendering frame!\n");
+// }
break;
}
@@ -1569,18 +2680,27 @@ void CEVRAllocatorPresenter::OnResetDevice() void CEVRAllocatorPresenter::RemoveAllSamples()
{
+ CAutoLock AutoLock(&m_ImageProcessingLock);
+
FlushSamples();
m_ScheduledSamples.RemoveAll();
m_FreeSamples.RemoveAll();
+ m_LastScheduledSampleTime = -1;
+ m_LastScheduledUncorrectedSampleTime = -1;
+ ASSERT(m_nUsedBuffer == 0);
+ m_nUsedBuffer = 0;
}
HRESULT CEVRAllocatorPresenter::GetFreeSample(IMFSample** ppSample)
{
- CAutoLock lock(this);
+ CAutoLock lock(&m_SampleQueueLock);
HRESULT hr = S_OK;
if (m_FreeSamples.GetCount() > 1) // <= Cannot use first free buffer (can be currently displayed)
+ {
+ InterlockedIncrement (&m_nUsedBuffer);
*ppSample = m_FreeSamples.RemoveHead().Detach();
+ }
else
hr = MF_E_SAMPLEALLOCATOR_EMPTY;
@@ -1588,13 +2708,17 @@ HRESULT CEVRAllocatorPresenter::GetFreeSample(IMFSample** ppSample) }
-HRESULT CEVRAllocatorPresenter::GetScheduledSample(IMFSample** ppSample)
+HRESULT CEVRAllocatorPresenter::GetScheduledSample(IMFSample** ppSample, int &_Count)
{
- CAutoLock lock(this);
+ CAutoLock lock(&m_SampleQueueLock);
HRESULT hr = S_OK;
- if (m_ScheduledSamples.GetCount() > 0)
+ _Count = m_ScheduledSamples.GetCount();
+ if (_Count > 0)
+ {
*ppSample = m_ScheduledSamples.RemoveHead().Detach();
+ --_Count;
+ }
else
hr = MF_E_SAMPLEALLOCATOR_EMPTY;
@@ -1604,7 +2728,13 @@ HRESULT CEVRAllocatorPresenter::GetScheduledSample(IMFSample** ppSample) void CEVRAllocatorPresenter::MoveToFreeList(IMFSample* pSample, bool bTail)
{
- CAutoLock lock(this);
+ CAutoLock lock(&m_SampleQueueLock);
+ InterlockedDecrement (&m_nUsedBuffer);
+ if (m_bPendingMediaFinished && m_nUsedBuffer == 0)
+ {
+ m_bPendingMediaFinished = false;
+ m_pSink->Notify (EC_COMPLETE, 0, 0);
+ }
if (bTail)
m_FreeSamples.AddTail (pSample);
else
@@ -1612,25 +2742,281 @@ void CEVRAllocatorPresenter::MoveToFreeList(IMFSample* pSample, bool bTail) }
-void CEVRAllocatorPresenter::MoveToScheduledList(IMFSample* pSample)
+void CEVRAllocatorPresenter::MoveToScheduledList(IMFSample* pSample, bool _bSorted)
{
- CAutoLock lock(this);
- m_ScheduledSamples.AddTail (pSample);
+
+ if (_bSorted)
+ {
+ CAutoLock lock(&m_SampleQueueLock);
+ // Insert sorted
+/* POSITION Iterator = m_ScheduledSamples.GetHeadPosition();
+
+ LONGLONG NewSampleTime;
+ pSample->GetSampleTime(&NewSampleTime);
+
+ while (Iterator != NULL)
+ {
+ POSITION CurrentPos = Iterator;
+ IMFSample *pIter = m_ScheduledSamples.GetNext(Iterator);
+ LONGLONG SampleTime;
+ pIter->GetSampleTime(&SampleTime);
+ if (NewSampleTime < SampleTime)
+ {
+ m_ScheduledSamples.InsertBefore(CurrentPos, pSample);
+ return;
+ }
+ }*/
+
+ m_ScheduledSamples.AddHead(pSample);
+ }
+ else
+ {
+
+ CAutoLock lock(&m_SampleQueueLock);
+
+ AppSettings& s = AfxGetAppSettings();
+ double ForceFPS = 0.0;
+// double ForceFPS = 59.94;
+// double ForceFPS = 23.976;
+ if (ForceFPS != 0.0)
+ m_rtTimePerFrame = 10000000.0 / ForceFPS;
+ LONGLONG Duration = m_rtTimePerFrame;
+ LONGLONG PrevTime = m_LastScheduledUncorrectedSampleTime;
+ LONGLONG Time;
+ LONGLONG SetDuration;
+ pSample->GetSampleDuration(&SetDuration);
+ pSample->GetSampleTime(&Time);
+ m_LastScheduledUncorrectedSampleTime = Time;
+
+ m_bCorrectedFrameTime = false;
+ double LastFP = m_LastScheduledSampleTimeFP;
+
+ LONGLONG Diff2 = PrevTime - m_LastScheduledSampleTimeFP*10000000.0;
+ LONGLONG Diff = Time - PrevTime;
+ if (PrevTime == -1)
+ Diff = 0;
+ if (Diff < 0)
+ Diff = -Diff;
+ if (Diff2 < 0)
+ Diff2 = -Diff2;
+ if (Diff < m_rtTimePerFrame*8 && m_rtTimePerFrame && Diff2 < m_rtTimePerFrame*8) // Detect seeking
+ {
+ int iPos = (m_DetectedFrameTimePos++) % 60;
+ LONGLONG Diff = Time - PrevTime;
+ if (PrevTime == -1)
+ Diff = 0;
+ m_DetectedFrameTimeHistory[iPos] = Diff;
+
+ if (m_DetectedFrameTimePos >= 10)
+ {
+ int nFrames = min(m_DetectedFrameTimePos, 60);
+ LONGLONG DectedSum = 0;
+ for (int i = 0; i < nFrames; ++i)
+ {
+ DectedSum += m_DetectedFrameTimeHistory[i];
+ }
+
+ double Average = double(DectedSum) / double(nFrames);
+ double DeviationSum = 0.0;
+ for (int i = 0; i < nFrames; ++i)
+ {
+ double Deviation = m_DetectedFrameTimeHistory[i] - Average;
+ DeviationSum += Deviation*Deviation;
+ }
+
+ double StdDev = sqrt(DeviationSum/double(nFrames));
+
+ m_DetectedFrameTimeStdDev = StdDev;
+
+ double DetectedRate = 1.0/ (double(DectedSum) / (nFrames * 10000000.0) );
+
+ double AllowedError = 0.0003;
+
+ static double AllowedValues[] = {60.0, 59.94, 50.0, 48.0, 47.952, 30.0, 29.97, 25.0, 24.0, 23.976};
+
+ int nAllowed = sizeof(AllowedValues) / sizeof(AllowedValues[0]);
+ for (int i = 0; i < nAllowed; ++i)
+ {
+ if (fabs(1.0 - DetectedRate / AllowedValues[i]) < AllowedError)
+ {
+ DetectedRate = AllowedValues[i];
+ break;
+ }
+ }
+
+ m_DetectedFrameTimeHistoryHisotry[m_DetectedFrameTimePos % 500] = DetectedRate;
+
+ class CAutoInt
+ {
+ public:
+
+ int m_Int;
+
+ CAutoInt()
+ {
+ m_Int = 0;
+ }
+ CAutoInt(int _Other)
+ {
+ m_Int = _Other;
+ }
+
+ operator int ()
+ {
+ return m_Int;
+ }
+
+ CAutoInt &operator ++ ()
+ {
+ ++m_Int;
+ return *this;
+ }
+ };
+
+
+ CMap<double, double, CAutoInt, CAutoInt> Map;
+
+ for (int i = 0; i < 500; ++i)
+ {
+ ++Map[m_DetectedFrameTimeHistoryHisotry[i]];
+ }
+
+ POSITION Pos = Map.GetStartPosition();
+ double BestVal = 0.0;
+ int BestNum = 5;
+ while (Pos)
+ {
+ double Key;
+ CAutoInt Value;
+ Map.GetNextAssoc(Pos, Key, Value);
+ if (Value.m_Int > BestNum && Key != 0.0)
+ {
+ BestNum = Value.m_Int;
+ BestVal = Key;
+ }
+ }
+
+ m_DetectedLock = false;
+ for (int i = 0; i < nAllowed; ++i)
+ {
+ if (BestVal == AllowedValues[i])
+ {
+ m_DetectedLock = true;
+ break;
+ }
+ }
+ if (BestVal != 0.0)
+ {
+ m_DetectedFrameRate = BestVal;
+ m_DetectedFrameTime = 1.0 / BestVal;
+ }
+ }
+
+ LONGLONG PredictedNext = PrevTime + m_rtTimePerFrame;
+ LONGLONG PredictedDiff = PredictedNext - Time;
+ if (PredictedDiff < 0)
+ PredictedDiff = -PredictedDiff;
+
+ if (m_DetectedFrameTime != 0.0
+ //&& PredictedDiff > 15000
+ && m_DetectedLock && s.m_RenderSettings.iEVREnableFrameTimeCorrection)
+ {
+ double CurrentTime = Time / 10000000.0;
+ double LastTime = m_LastScheduledSampleTimeFP;
+ double PredictedTime = LastTime + m_DetectedFrameTime;
+ if (fabs(PredictedTime - CurrentTime) > 0.0015) // 1.5 ms wrong, lets correct
+ {
+ CurrentTime = PredictedTime;
+ Time = CurrentTime * 10000000.0;
+ pSample->SetSampleTime(Time);
+ pSample->SetSampleDuration(m_DetectedFrameTime * 10000000.0);
+ m_bCorrectedFrameTime = true;
+ m_FrameTimeCorrection = 30;
+ }
+ m_LastScheduledSampleTimeFP = CurrentTime;;
+ }
+ else
+ m_LastScheduledSampleTimeFP = Time / 10000000.0;
+ }
+ else
+ {
+ m_LastScheduledSampleTimeFP = Time / 10000000.0;
+ if (Diff > m_rtTimePerFrame*8)
+ {
+ // Seek
+ m_bSignaledStarvation = false;
+ m_DetectedFrameTimePos = 0;
+ m_DetectedLock = false;
+ }
+ }
+
+// TRACE("Time: %f %f %f\n", Time / 10000000.0, SetDuration / 10000000.0, m_DetectedFrameRate);
+ if (!m_bCorrectedFrameTime && m_FrameTimeCorrection)
+ --m_FrameTimeCorrection;
+
+#if 0
+ if (Time <= m_LastScheduledUncorrectedSampleTime && m_LastScheduledSampleTime >= 0)
+ PrevTime = m_LastScheduledSampleTime;
+
+ m_bCorrectedFrameTime = false;
+ if (PrevTime != -1 && (Time >= PrevTime - ((Duration*20)/9) || Time == 0) || ForceFPS != 0.0)
+ {
+ if (Time - PrevTime > ((Duration*20)/9) && Time - PrevTime < Duration * 8 || Time == 0 || ((Time - PrevTime) < (Duration / 11)) || ForceFPS != 0.0)
+ {
+ // Error!!!!
+ Time = PrevTime + Duration;
+ pSample->SetSampleTime(Time);
+ pSample->SetSampleDuration(Duration);
+ m_bCorrectedFrameTime = true;
+ TRACE("Corrected invalid sample time\n");
+ }
+ }
+ if (Time+Duration*10 < m_LastScheduledSampleTime)
+ {
+ // Flush when repeating movie
+ FlushSamplesInternal();
+ }
+#endif
+
+#if 0
+ static LONGLONG LastDuration = 0;
+ LONGLONG SetDuration = m_rtTimePerFrame;
+ pSample->GetSampleDuration(&SetDuration);
+ if (SetDuration != LastDuration)
+ {
+ TRACE("Old duration: %I64d New duration: %I64d\n", LastDuration, SetDuration);
+ }
+ LastDuration = SetDuration;
+#endif
+ m_LastScheduledSampleTime = Time;
+
+ m_ScheduledSamples.AddTail(pSample);
+
+ }
}
+
void CEVRAllocatorPresenter::FlushSamples()
{
CAutoLock lock(this);
+ CAutoLock lock2(&m_SampleQueueLock);
+
+ FlushSamplesInternal();
+ m_LastScheduledSampleTime = -1;
+}
- m_nUsedBuffer = 0;
+void CEVRAllocatorPresenter::FlushSamplesInternal()
+{
while (m_ScheduledSamples.GetCount() > 0)
{
CComPtr<IMFSample> pMFSample;
pMFSample = m_ScheduledSamples.RemoveHead();
MoveToFreeList (pMFSample, true);
-
- WaitForSingleObject (m_hSemPicture, 0);
}
+
+ m_LastSampleOffset = 0;
+ m_bLastSampleOffsetValid = false;
+ m_bSignaledStarvation = false;
}
\ No newline at end of file diff --git a/src/apps/mplayerc/FGFilter.h b/src/apps/mplayerc/FGFilter.h index 69e4d5f98..075ee9736 100644 --- a/src/apps/mplayerc/FGFilter.h +++ b/src/apps/mplayerc/FGFilter.h @@ -88,7 +88,7 @@ public: CheckPointer(ppBF, E_POINTER);
HRESULT hr = S_OK;
- CComPtr<IBaseFilter> pBF = new T(NULL, &hr);
+ CComPtr<IBaseFilter> pBF = DNew T(NULL, &hr);
if(FAILED(hr)) return hr;
*ppBF = pBF.Detach();
diff --git a/src/apps/mplayerc/FGManager.cpp b/src/apps/mplayerc/FGManager.cpp index 4d2cf4b9f..03a54d2a1 100644 --- a/src/apps/mplayerc/FGManager.cpp +++ b/src/apps/mplayerc/FGManager.cpp @@ -187,7 +187,7 @@ HRESULT CFGManager::EnumSourceFilters(LPCWSTR lpcwstrFileName, CFGFilterList& fl if(ext == _T(".dvr-ms")) // doh, this is stupid
{
- fl.Insert(new CFGFilterRegistry(CLSID_StreamBufferSource, MERIT64_PREFERRED), 0);
+ fl.Insert(DNew CFGFilterRegistry(CLSID_StreamBufferSource, MERIT64_PREFERRED), 0);
}
TCHAR buff[256], buff2[256];
@@ -263,15 +263,15 @@ HRESULT CFGManager::EnumSourceFilters(LPCWSTR lpcwstrFileName, CFGFilterList& fl {
len = countof(buff);
if(ERROR_SUCCESS == exts.QueryStringValue(CString(ext), buff, &len))
- fl.Insert(new CFGFilterRegistry(GUIDFromCString(buff)), 4);
+ fl.Insert(DNew CFGFilterRegistry(GUIDFromCString(buff)), 4);
}
len = countof(buff);
if(ERROR_SUCCESS == key.QueryStringValue(_T("Source Filter"), buff, &len))
- fl.Insert(new CFGFilterRegistry(GUIDFromCString(buff)), 5);
+ fl.Insert(DNew CFGFilterRegistry(GUIDFromCString(buff)), 5);
}
- fl.Insert(new CFGFilterRegistry(CLSID_URLReader), 6);
+ fl.Insert(DNew CFGFilterRegistry(CLSID_URLReader), 6);
}
else
{
@@ -315,7 +315,7 @@ HRESULT CFGManager::EnumSourceFilters(LPCWSTR lpcwstrFileName, CFGFilterList& fl {
if(CheckBytes(hFile, CString(buff)))
{
- CFGFilter* pFGF = new CFGFilterRegistry(clsid);
+ CFGFilter* pFGF = DNew CFGFilterRegistry(clsid);
pFGF->AddType(majortype, subtype);
fl.Insert(pFGF, 9);
break;
@@ -352,7 +352,7 @@ HRESULT CFGManager::EnumSourceFilters(LPCWSTR lpcwstrFileName, CFGFilterList& fl if(ERROR_SUCCESS == key.QueryStringValue(_T("Subtype"), buff, &len))
subtype = GUIDFromCString(buff);
- CFGFilter* pFGF = new CFGFilterRegistry(clsid);
+ CFGFilter* pFGF = DNew CFGFilterRegistry(clsid);
pFGF->AddType(majortype, subtype);
fl.Insert(pFGF, 7);
}
@@ -364,7 +364,7 @@ HRESULT CFGManager::EnumSourceFilters(LPCWSTR lpcwstrFileName, CFGFilterList& fl CloseHandle(hFile);
}
- CFGFilter* pFGF = new CFGFilterRegistry(CLSID_AsyncReader);
+ CFGFilter* pFGF = DNew CFGFilterRegistry(CLSID_AsyncReader);
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_NULL);
fl.Insert(pFGF, 9);
@@ -418,7 +418,7 @@ HRESULT CFGManager::AddSourceFilter(CFGFilter* pFGF, LPCWSTR lpcwstrFileName, LP || pmt->subtype == GUIDFromCString(_T("{D51BD5AE-7548-11CF-A520-0080C77EF58A}")))
{
RemoveFilter(pBF);
- pFGF = new CFGFilterRegistry(CLSID_NetShowSource);
+ pFGF = DNew CFGFilterRegistry(CLSID_NetShowSource);
hr = AddSourceFilter(pFGF, lpcwstrFileName, lpcwstrFilterName, ppBF);
delete pFGF;
return hr;
@@ -663,7 +663,7 @@ STDMETHODIMP CFGManager::Connect(IPin* pPinOut, IPin* pPinIn) {
for(CComPtr<IMoniker> pMoniker; S_OK == pEM->Next(1, &pMoniker, NULL); pMoniker = NULL)
{
- CFGFilterRegistry* pFGF = new CFGFilterRegistry(pMoniker);
+ CFGFilterRegistry* pFGF = DNew CFGFilterRegistry(pMoniker);
fl.Insert(pFGF, 0, pFGF->CheckTypes(types, true));
}
}
@@ -765,7 +765,7 @@ STDMETHODIMP CFGManager::Connect(IPin* pPinOut, IPin* pPinIn) if(fDeadEnd)
{
- CAutoPtr<CStreamDeadEnd> psde(new CStreamDeadEnd());
+ CAutoPtr<CStreamDeadEnd> psde(DNew CStreamDeadEnd());
psde->AddTailList(&m_streampath);
int skip = 0;
BeginEnumMediaTypes(pPinOut, pEM, pmt)
@@ -1222,7 +1222,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_SHOUTCAST
if(src & SRC_SHOUTCAST)
{
- pFGF = new CFGFilterInternal<CShoutcastSource>();
+ pFGF = DNew CFGFilterInternal<CShoutcastSource>();
pFGF->m_protocols.AddTail(_T("http"));
m_source.AddTail(pFGF);
}
@@ -1231,7 +1231,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_UDP
// if(src & SRC_UDP)
{
- pFGF = new CFGFilterInternal<CUDPReader>();
+ pFGF = DNew CFGFilterInternal<CUDPReader>();
pFGF->m_protocols.AddTail(_T("udp"));
m_source.AddTail(pFGF);
}
@@ -1240,7 +1240,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_AVI
if(src & SRC_AVI)
{
- pFGF = new CFGFilterInternal<CAviSourceFilter>();
+ pFGF = DNew CFGFilterInternal<CAviSourceFilter>();
pFGF->m_chkbytes.AddTail(_T("0,4,,52494646,8,4,,41564920"));
pFGF->m_chkbytes.AddTail(_T("0,4,,52494646,8,4,,41564958"));
m_source.AddTail(pFGF);
@@ -1250,7 +1250,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_MP4
if(src & SRC_MP4)
{
- pFGF = new CFGFilterInternal<CMP4SourceFilter>();
+ pFGF = DNew CFGFilterInternal<CMP4SourceFilter>();
pFGF->m_chkbytes.AddTail(_T("4,4,,66747970")); // ftyp
pFGF->m_chkbytes.AddTail(_T("4,4,,6d6f6f76")); // moov
pFGF->m_chkbytes.AddTail(_T("4,4,,6d646174")); // mdat
@@ -1265,7 +1265,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_FLV
if(src & SRC_FLV)
{
- pFGF = new CFGFilterInternal<CFLVSourceFilter>();
+ pFGF = DNew CFGFilterInternal<CFLVSourceFilter>();
pFGF->m_chkbytes.AddTail(_T("0,4,,464C5601")); // FLV (v1)
m_source.AddTail(pFGF);
}
@@ -1274,7 +1274,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_MATROSKA
if(src & SRC_MATROSKA)
{
- pFGF = new CFGFilterInternal<CMatroskaSourceFilter>();
+ pFGF = DNew CFGFilterInternal<CMatroskaSourceFilter>();
pFGF->m_chkbytes.AddTail(_T("0,4,,1A45DFA3"));
m_source.AddTail(pFGF);
}
@@ -1283,7 +1283,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_REALMEDIA
if(src & SRC_REALMEDIA)
{
- pFGF = new CFGFilterInternal<CRealMediaSourceFilter>();
+ pFGF = DNew CFGFilterInternal<CRealMediaSourceFilter>();
pFGF->m_chkbytes.AddTail(_T("0,4,,2E524D46"));
m_source.AddTail(pFGF);
}
@@ -1292,7 +1292,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_DSM
if(src & SRC_DSM)
{
- pFGF = new CFGFilterInternal<CDSMSourceFilter>();
+ pFGF = DNew CFGFilterInternal<CDSMSourceFilter>();
pFGF->m_chkbytes.AddTail(_T("0,4,,44534D53"));
m_source.AddTail(pFGF);
}
@@ -1301,7 +1301,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_FLIC
if(src & SRC_FLIC)
{
- pFGF = new CFGFilterInternal<CFLICSource>();
+ pFGF = DNew CFGFilterInternal<CFLICSource>();
pFGF->m_chkbytes.AddTail(_T("4,2,,11AF"));
pFGF->m_chkbytes.AddTail(_T("4,2,,12AF"));
pFGF->m_extensions.AddTail(_T(".fli"));
@@ -1313,7 +1313,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_FLAC
if(src & SRC_FLAC)
{
- pFGF = new CFGFilterInternal<CFlacSource>();
+ pFGF = DNew CFGFilterInternal<CFlacSource>();
pFGF->m_chkbytes.AddTail(_T("0,4,,664C6143"));
pFGF->m_extensions.AddTail(_T(".flac"));
m_source.AddTail(pFGF);
@@ -1323,7 +1323,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_CDDA
if(src & SRC_CDDA)
{
- pFGF = new CFGFilterInternal<CCDDAReader>();
+ pFGF = DNew CFGFilterInternal<CCDDAReader>();
pFGF->m_extensions.AddTail(_T(".cda"));
m_source.AddTail(pFGF);
}
@@ -1332,7 +1332,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_CDXA
if(src & SRC_CDXA)
{
- pFGF = new CFGFilterInternal<CCDXAReader>();
+ pFGF = DNew CFGFilterInternal<CCDXAReader>();
pFGF->m_chkbytes.AddTail(_T("0,4,,52494646,8,4,,43445841"));
m_source.AddTail(pFGF);
}
@@ -1341,7 +1341,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_VTS
if(src & SRC_VTS)
{
- pFGF = new CFGFilterInternal<CVTSReader>();
+ pFGF = DNew CFGFilterInternal<CVTSReader>();
pFGF->m_chkbytes.AddTail(_T("0,12,,445644564944454F2D565453"));
m_source.AddTail(pFGF);
}
@@ -1354,7 +1354,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) {
if(src & SRC_D2V)
{
- pFGF = new CFGFilterInternal<CD2VSource>();
+ pFGF = DNew CFGFilterInternal<CD2VSource>();
pFGF->m_chkbytes.AddTail(_T("0,18,,4456443241564950726F6A65637446696C65"));
pFGF->m_extensions.AddTail(_T(".d2v"));
m_source.AddTail(pFGF);
@@ -1368,7 +1368,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) {
if(src & SRC_RADGT)
{
- pFGF = new CFGFilterInternal<CRadGtSourceFilter>();
+ pFGF = DNew CFGFilterInternal<CRadGtSourceFilter>();
pFGF->m_chkbytes.AddTail(_T("0,3,,534D4B"));
pFGF->m_chkbytes.AddTail(_T("0,3,,42494B"));
pFGF->m_extensions.AddTail(_T(".smk"));
@@ -1381,7 +1381,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_ROQ
if(src & SRC_ROQ)
{
- pFGF = new CFGFilterInternal<CRoQSourceFilter>();
+ pFGF = DNew CFGFilterInternal<CRoQSourceFilter>();
pFGF->m_chkbytes.AddTail(_T("0,8,,8410FFFFFFFF1E00"));
m_source.AddTail(pFGF);
}
@@ -1390,7 +1390,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_OGG
if(src & SRC_OGG)
{
- pFGF = new CFGFilterInternal<COggSourceFilter>();
+ pFGF = DNew CFGFilterInternal<COggSourceFilter>();
pFGF->m_chkbytes.AddTail(_T("0,4,,4F676753"));
m_source.AddTail(pFGF);
}
@@ -1401,7 +1401,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) {
if(src & SRC_NUT)
{
- pFGF = new CFGFilterInternal<CNutSourceFilter>();
+ pFGF = DNew CFGFilterInternal<CNutSourceFilter>();
pFGF->m_chkbytes.AddTail(_T("0,8,,F9526A624E55544D"));
m_source.AddTail(pFGF);
}
@@ -1413,7 +1413,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) {
if(src & SRC_DIRAC)
{
- pFGF = new CFGFilterInternal<CDiracSourceFilter>();
+ pFGF = DNew CFGFilterInternal<CDiracSourceFilter>();
pFGF->m_chkbytes.AddTail(_T("0,8,,4B572D4449524143"));
m_source.AddTail(pFGF);
}
@@ -1423,7 +1423,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_MPEG
if(src & SRC_MPEG)
{
- pFGF = new CFGFilterInternal<CMpegSourceFilter>();
+ pFGF = DNew CFGFilterInternal<CMpegSourceFilter>();
pFGF->m_chkbytes.AddTail(_T("0,16,FFFFFFFFF100010001800001FFFFFFFF,000001BA2100010001800001000001BB"));
pFGF->m_chkbytes.AddTail(_T("0,5,FFFFFFFFC0,000001BA40"));
pFGF->m_chkbytes.AddTail(_T("0,1,,47,188,1,,47,376,1,,47"));
@@ -1437,7 +1437,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_DTSAC3
if(src & SRC_DTSAC3)
{
- pFGF = new CFGFilterInternal<CDTSAC3Source>();
+ pFGF = DNew CFGFilterInternal<CDTSAC3Source>();
pFGF->m_chkbytes.AddTail(_T("0,4,,7FFE8001"));
pFGF->m_chkbytes.AddTail(_T("0,2,,0B77"));
pFGF->m_chkbytes.AddTail(_T("0,2,,770B"));
@@ -1450,7 +1450,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_MPEGAUDIO
if(src & SRC_MPA)
{
- pFGF = new CFGFilterInternal<CMpaSourceFilter>();
+ pFGF = DNew CFGFilterInternal<CMpaSourceFilter>();
pFGF->m_chkbytes.AddTail(_T("0,2,FFE0,FFE0"));
pFGF->m_chkbytes.AddTail(_T("0,10,FFFFFF00000080808080,49443300000000000000"));
m_source.AddTail(pFGF);
@@ -1459,7 +1459,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) if(AfxGetAppSettings().fUseWMASFReader)
{
- pFGF = new CFGFilterRegistry(CLSID_WMAsfReader);
+ pFGF = DNew CFGFilterRegistry(CLSID_WMAsfReader);
pFGF->m_chkbytes.AddTail(_T("0,4,,3026B275"));
pFGF->m_chkbytes.AddTail(_T("0,4,,D129E2D6"));
m_source.AddTail(pFGF);
@@ -1467,7 +1467,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_AVI2AC3
// hmmm, shouldn't there be an option in the GUI to enable/disable this filter?
- pFGF = new CFGFilterInternal<CAVI2AC3Filter>(L"AVI<->AC3/DTS", MERIT64(0x00680000)+1);
+ pFGF = DNew CFGFilterInternal<CAVI2AC3Filter>(L"AVI<->AC3/DTS", MERIT64(0x00680000)+1);
pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_WAVE_DOLBY_AC3);
pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_WAVE_DTS);
m_transform.AddTail(pFGF);
@@ -1475,9 +1475,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_MATROSKA
if(src & SRC_MATROSKA) {
- pFGF = new CFGFilterInternal<CMatroskaSplitterFilter>(L"Matroska Splitter", MERIT64_ABOVE_DSHOW);
+ pFGF = DNew CFGFilterInternal<CMatroskaSplitterFilter>(L"Matroska Splitter", MERIT64_ABOVE_DSHOW);
} else {
- pFGF = new CFGFilterInternal<CMatroskaSplitterFilter>(L"Matroska Splitter (low merit)", MERIT64_DO_USE);
+ pFGF = DNew CFGFilterInternal<CMatroskaSplitterFilter>(L"Matroska Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Matroska);
pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
@@ -1486,9 +1486,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_REALMEDIA
if(src & SRC_REALMEDIA) {
- pFGF = new CFGFilterInternal<CRealMediaSplitterFilter>(L"RealMedia Splitter", MERIT64_ABOVE_DSHOW);
+ pFGF = DNew CFGFilterInternal<CRealMediaSplitterFilter>(L"RealMedia Splitter", MERIT64_ABOVE_DSHOW);
} else {
- pFGF = new CFGFilterInternal<CRealMediaSplitterFilter>(L"RealMedia Splitter (low merit)", MERIT64_DO_USE);
+ pFGF = DNew CFGFilterInternal<CRealMediaSplitterFilter>(L"RealMedia Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_RealMedia);
pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
@@ -1497,9 +1497,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_AVI
if(src & SRC_AVI) {
- pFGF = new CFGFilterInternal<CAviSplitterFilter>(L"Avi Splitter", MERIT64_ABOVE_DSHOW);
+ pFGF = DNew CFGFilterInternal<CAviSplitterFilter>(L"Avi Splitter", MERIT64_ABOVE_DSHOW);
} else {
- pFGF = new CFGFilterInternal<CAviSplitterFilter>(L"Avi Splitter (low merit)", MERIT64_DO_USE);
+ pFGF = DNew CFGFilterInternal<CAviSplitterFilter>(L"Avi Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Avi);
pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
@@ -1510,9 +1510,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) __if_exists(CRadGtSplitterFilter)
{
if(src & SRC_RADGT) {
- pFGF = new CFGFilterInternal<CRadGtSplitterFilter>(L"RadGt Splitter", MERIT64_ABOVE_DSHOW);
+ pFGF = DNew CFGFilterInternal<CRadGtSplitterFilter>(L"RadGt Splitter", MERIT64_ABOVE_DSHOW);
} else {
- pFGF = new CFGFilterInternal<CRadGtSplitterFilter>(L"RadGt Splitter (low merit)", MERIT64_DO_USE);
+ pFGF = DNew CFGFilterInternal<CRadGtSplitterFilter>(L"RadGt Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Bink);
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Smacker);
@@ -1523,9 +1523,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_ROQ
if(src & SRC_ROQ) {
- pFGF = new CFGFilterInternal<CRoQSplitterFilter>(L"RoQ Splitter", MERIT64_ABOVE_DSHOW);
+ pFGF = DNew CFGFilterInternal<CRoQSplitterFilter>(L"RoQ Splitter", MERIT64_ABOVE_DSHOW);
} else {
- pFGF = new CFGFilterInternal<CRoQSplitterFilter>(L"RoQ Splitter (low merit)", MERIT64_DO_USE);
+ pFGF = DNew CFGFilterInternal<CRoQSplitterFilter>(L"RoQ Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_RoQ);
pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
@@ -1534,9 +1534,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_OGG
if(src & SRC_OGG) {
- pFGF = new CFGFilterInternal<COggSplitterFilter>(L"Ogg Splitter", MERIT64_ABOVE_DSHOW);
+ pFGF = DNew CFGFilterInternal<COggSplitterFilter>(L"Ogg Splitter", MERIT64_ABOVE_DSHOW);
} else {
- pFGF = new CFGFilterInternal<COggSplitterFilter>(L"Ogg Splitter (low merit)", MERIT64_DO_USE);
+ pFGF = DNew CFGFilterInternal<COggSplitterFilter>(L"Ogg Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Ogg);
pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
@@ -1547,9 +1547,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) __if_exists(CNutSplitterFilter)
{
if(src & SRC_NUT) {
- pFGF = new CFGFilterInternal<CNutSplitterFilter>(L"Nut Splitter", MERIT64_ABOVE_DSHOW);
+ pFGF = DNew CFGFilterInternal<CNutSplitterFilter>(L"Nut Splitter", MERIT64_ABOVE_DSHOW);
} else {
- pFGF = new CFGFilterInternal<CNutSplitterFilter>(L"Nut Splitter (low merit)", MERIT64_DO_USE);
+ pFGF = DNew CFGFilterInternal<CNutSplitterFilter>(L"Nut Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Nut);
pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
@@ -1559,9 +1559,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_MPEG
if(src & SRC_MPEG) {
- pFGF = new CFGFilterInternal<CMpegSplitterFilter>(L"Mpeg Splitter", MERIT64_ABOVE_DSHOW);
+ pFGF = DNew CFGFilterInternal<CMpegSplitterFilter>(L"Mpeg Splitter", MERIT64_ABOVE_DSHOW);
} else {
- pFGF = new CFGFilterInternal<CMpegSplitterFilter>(L"Mpeg Splitter (low merit)", MERIT64_DO_USE);
+ pFGF = DNew CFGFilterInternal<CMpegSplitterFilter>(L"Mpeg Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG1System);
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG2_PROGRAM);
@@ -1575,9 +1575,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) __if_exists(CDiracSplitterFilter)
{
if(src & SRC_DIRAC) {
- pFGF = new CFGFilterInternal<CDiracSplitterFilter>(L"Dirac Splitter", MERIT64_ABOVE_DSHOW);
+ pFGF = DNew CFGFilterInternal<CDiracSplitterFilter>(L"Dirac Splitter", MERIT64_ABOVE_DSHOW);
} else {
- pFGF = new CFGFilterInternal<CDiracSplitterFilter>(L"Dirac Splitter (low merit)", MERIT64_DO_USE);
+ pFGF = DNew CFGFilterInternal<CDiracSplitterFilter>(L"Dirac Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Dirac);
pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
@@ -1587,9 +1587,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_MPEGAUDIO
if(src & SRC_MPA) {
- pFGF = new CFGFilterInternal<CMpaSplitterFilter>(L"Mpa Splitter", MERIT64_ABOVE_DSHOW);
+ pFGF = DNew CFGFilterInternal<CMpaSplitterFilter>(L"Mpa Splitter", MERIT64_ABOVE_DSHOW);
} else {
- pFGF = new CFGFilterInternal<CMpaSplitterFilter>(L"Mpa Splitter (low merit)", MERIT64_DO_USE);
+ pFGF = DNew CFGFilterInternal<CMpaSplitterFilter>(L"Mpa Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG1Audio);
pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
@@ -1598,9 +1598,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_DSM
if(src & SRC_DSM) {
- pFGF = new CFGFilterInternal<CDSMSplitterFilter>(L"DSM Splitter", MERIT64_ABOVE_DSHOW);
+ pFGF = DNew CFGFilterInternal<CDSMSplitterFilter>(L"DSM Splitter", MERIT64_ABOVE_DSHOW);
} else {
- pFGF = new CFGFilterInternal<CDSMSplitterFilter>(L"DSM Splitter (low merit)", MERIT64_DO_USE);
+ pFGF = DNew CFGFilterInternal<CDSMSplitterFilter>(L"DSM Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_DirectShowMedia);
pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
@@ -1609,9 +1609,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_MP4
if(src & SRC_MP4) {
- pFGF = new CFGFilterInternal<CMP4SplitterFilter>(L"MP4 Splitter", MERIT64_ABOVE_DSHOW);
+ pFGF = DNew CFGFilterInternal<CMP4SplitterFilter>(L"MP4 Splitter", MERIT64_ABOVE_DSHOW);
} else {
- pFGF = new CFGFilterInternal<CMP4SplitterFilter>(L"MP4 Splitter (low merit)", MERIT64_DO_USE);
+ pFGF = DNew CFGFilterInternal<CMP4SplitterFilter>(L"MP4 Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MP4);
pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
@@ -1620,9 +1620,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_SOURCEFILTER_FLV
if(src & SRC_FLV) {
- pFGF = new CFGFilterInternal<CFLVSplitterFilter>(L"FLV Splitter", MERIT64_ABOVE_DSHOW);
+ pFGF = DNew CFGFilterInternal<CFLVSplitterFilter>(L"FLV Splitter", MERIT64_ABOVE_DSHOW);
} else {
- pFGF = new CFGFilterInternal<CFLVSplitterFilter>(L"FLV Splitter (low merit)", MERIT64_DO_USE);
+ pFGF = DNew CFGFilterInternal<CFLVSplitterFilter>(L"FLV Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_FLV);
pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
@@ -1633,7 +1633,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) // Transform filters
#if INTERNAL_DECODER_MPEG1
- pFGF = new CFGFilterInternal<CMpeg2DecFilter>(
+ pFGF = DNew CFGFilterInternal<CMpeg2DecFilter>(
(tra & TRA_MPEG1) ? ResStr(IDS_FGMANAGER_0) : L"MPEG-1 Video Decoder (low merit)",
(tra & TRA_MPEG1) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG1Packet);
@@ -1642,7 +1642,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #endif
#if INTERNAL_DECODER_MPEG2
- pFGF = new CFGFilterInternal<CMpeg2DecFilter>(
+ pFGF = DNew CFGFilterInternal<CMpeg2DecFilter>(
(tra & TRA_MPEG2) ? ResStr(IDS_FGMANAGER_1) : L"MPEG-2 Video Decoder (low merit)",
(tra & TRA_MPEG2) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
@@ -1653,7 +1653,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #endif
#if INTERNAL_DECODER_MPEGAUDIO
- pFGF = new CFGFilterInternal<CMpaDecFilter>(
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
(tra & TRA_MPA) ? ResStr(IDS_FGMANAGER_2) : L"MPEG-1 Audio Decoder (low merit)",
(tra & TRA_MPA) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MP3);
@@ -1662,7 +1662,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG1Packet);
m_transform.AddTail(pFGF);
- pFGF = new CFGFilterInternal<CMpaDecFilter>(
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
(tra & TRA_MPA) ? ResStr(IDS_FGMANAGER_3) : L"MPEG-2 Audio Decoder (low merit)",
(tra & TRA_MPA) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_AUDIO);
@@ -1673,7 +1673,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #endif
#if INTERNAL_DECODER_LPCM
- pFGF = new CFGFilterInternal<CMpaDecFilter>(
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
(tra & TRA_LPCM) ? ResStr(IDS_FGMANAGER_4) : L"LPCM Audio Decoder (low merit)",
(tra & TRA_LPCM) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_DVD_LPCM_AUDIO);
@@ -1685,7 +1685,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #endif
#if INTERNAL_DECODER_AC3
- pFGF = new CFGFilterInternal<CMpaDecFilter>(
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
(tra & TRA_AC3) ? ResStr(IDS_FGMANAGER_5) : L"AC3 Audio Decoder (low merit)",
(tra & TRA_AC3) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_DOLBY_AC3);
@@ -1697,7 +1697,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #endif
#if INTERNAL_DECODER_DTS
- pFGF = new CFGFilterInternal<CMpaDecFilter>(
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
(tra & TRA_DTS) ? ResStr(IDS_AG_DTS_DECODER) : L"DTS Decoder (low merit)",
(tra & TRA_DTS) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_DTS);
@@ -1709,7 +1709,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #endif
#if INTERNAL_DECODER_AAC
- pFGF = new CFGFilterInternal<CMpaDecFilter>(
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
(tra & TRA_AAC) ? ResStr(IDS_AG_AAC_DECODER) : L"AAC Decoder (low merit)",
(tra & TRA_AAC) ? MERIT64_ABOVE_DSHOW+1 : MERIT64_DO_USE);
pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_AAC);
@@ -1728,7 +1728,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #endif
#if INTERNAL_DECODER_PS2AUDIO
- pFGF = new CFGFilterInternal<CMpaDecFilter>(
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
(tra & TRA_PS2AUD) ? ResStr(IDS_FGMANAGER_8) : L"PS2 Audio Decoder (low merit)",
(tra & TRA_PS2AUD) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_PS2_PCM);
@@ -1739,7 +1739,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #endif
#if INTERNAL_DECODER_REALVIDEO
- pFGF = new CFGFilterInternal<CRealVideoDecoder>(
+ pFGF = DNew CFGFilterInternal<CRealVideoDecoder>(
(tra & TRA_RV) ? ResStr(IDS_FGMANAGER_9) : L"RealVideo Decoder (low merit)",
(tra & TRA_RV) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV10);
@@ -1750,7 +1750,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #endif
#if INTERNAL_DECODER_REALAUDIO
- pFGF = new CFGFilterInternal<CRealAudioDecoder>(
+ pFGF = DNew CFGFilterInternal<CRealAudioDecoder>(
(tra & TRA_RA) ? ResStr(IDS_FGMANAGER_10) : L"RealAudio Decoder (low merit)",
(tra & TRA_RA) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_14_4);
@@ -1764,7 +1764,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #endif
#if INTERNAL_DECODER_VORBIS
- pFGF = new CFGFilterInternal<CMpaDecFilter>(
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
(tra & TRA_VORBIS) ? ResStr(IDS_FGMANAGER_11) : L"Vorbis Audio Decoder (low merit)",
(tra & TRA_VORBIS) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_Vorbis2);
@@ -1772,7 +1772,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #endif
#if INTERNAL_DECODER_FLAC
- pFGF = new CFGFilterInternal<CMpaDecFilter>(
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
(tra & TRA_FLAC) ? L"Flac Audio Decoder" : L"Flac Audio Decoder (low merit)", // TODO : put in resource !
(tra & TRA_FLAC) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_FLAC_FRAMED);
@@ -1780,7 +1780,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #endif
#if INTERNAL_DECODER_NELLYMOSER
- pFGF = new CFGFilterInternal<CMpaDecFilter>(
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
(tra & TRA_NELLY) ? L"Nellymoser Audio Decoder" : L"Nellymoser Audio Decoder (low merit)", // TODO : put in resource !
(tra & TRA_NELLY) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NELLYMOSER);
@@ -1788,13 +1788,13 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #endif
#if INTERNAL_DECODER_ROQ
- pFGF = new CFGFilterInternal<CRoQVideoDecoder>(
+ pFGF = DNew CFGFilterInternal<CRoQVideoDecoder>(
(tra & TRA_RV) ? ResStr(IDS_FGMANAGER_12) : L"RoQ Video Decoder (low merit)",
(tra & TRA_RV) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RoQV);
m_transform.AddTail(pFGF);
- pFGF = new CFGFilterInternal<CRoQAudioDecoder>(
+ pFGF = DNew CFGFilterInternal<CRoQAudioDecoder>(
(tra & TRA_RA) ? ResStr(IDS_FGMANAGER_13) : L"RoQ Audio Decoder (low merit)",
(tra & TRA_RA) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_RoQA);
@@ -1804,7 +1804,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) #if INTERNAL_DECODER_DIRAC
__if_exists(CDiracVideoDecoder)
{
- pFGF = new CFGFilterInternal<CDiracVideoDecoder>(
+ pFGF = DNew CFGFilterInternal<CDiracVideoDecoder>(
(tra & TRA_DIRAC) ? ResStr(IDS_FGMANAGER_14) : L"Dirac Video Decoder (low merit)",
(tra & TRA_DIRAC) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DiracVideo);
@@ -1812,7 +1812,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) }
#endif
- pFGF = new CFGFilterInternal<CNullTextRenderer>(L"NullTextRenderer", MERIT64_DO_USE);
+ pFGF = DNew CFGFilterInternal<CNullTextRenderer>(L"NullTextRenderer", MERIT64_DO_USE);
pFGF->AddType(MEDIATYPE_Text, MEDIASUBTYPE_NULL);
pFGF->AddType(MEDIATYPE_ScriptCommand, MEDIASUBTYPE_NULL);
pFGF->AddType(MEDIATYPE_Subtitle, MEDIASUBTYPE_NULL);
@@ -1824,7 +1824,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) // High merit MPC Video Decoder
#if INCLUDE_MPC_VIDEO_DECODER | INCLUDE_MPC_DXVA_VIDEO_DECODER
- pFGF = new CFGFilterInternal<CMPCVideoDecFilter>(_T("MPC Video Decoder"), MERIT64_ABOVE_DSHOW);
+ pFGF = DNew CFGFilterInternal<CMPCVideoDecFilter>(_T("MPC Video Decoder"), MERIT64_ABOVE_DSHOW);
#if INTERNAL_DECODER_FLV
if (ffmpeg_filters & FFM_FLV4)
{
@@ -2004,7 +2004,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) m_transform.AddTail(pFGF);
// Low merit MPC Video Decoder
- pFGF = new CFGFilterInternal<CMPCVideoDecFilter>(_T("MPC Video Decoder (low merit)"), MERIT64_DO_USE);
+ pFGF = DNew CFGFilterInternal<CMPCVideoDecFilter>(_T("MPC Video Decoder (low merit)"), MERIT64_DO_USE);
#if INTERNAL_DECODER_FLV
if (!(ffmpeg_filters & FFM_FLV4))
{
@@ -2187,7 +2187,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) // Low merit MPC Audio Decoder
/*
// TODO : not finished!
- pFGF = new CFGFilterInternal<CMPCAudioDecFilter>(_T("MPC Audio Decoder (low merit)"), MERIT64_ABOVE_DSHOW);
+ pFGF = DNew CFGFilterInternal<CMPCAudioDecFilter>(_T("MPC Audio Decoder (low merit)"), MERIT64_ABOVE_DSHOW);
pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_IMA_AMV);
m_transform.AddTail(pFGF);
*/
@@ -2205,19 +2205,19 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) // "Subtitle Mixer" makes an access violation around the
// 11-12th media type when enumerating them on its output.
- m_transform.AddTail(new CFGFilterRegistry(GUIDFromCString(_T("{00A95963-3BE5-48C0-AD9F-3356D67EA09D}")), MERIT64_DO_NOT_USE));
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{00A95963-3BE5-48C0-AD9F-3356D67EA09D}")), MERIT64_DO_NOT_USE));
// ISCR suxx
- m_transform.AddTail(new CFGFilterRegistry(GUIDFromCString(_T("{48025243-2D39-11CE-875D-00608CB78066}")), MERIT64_DO_NOT_USE));
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{48025243-2D39-11CE-875D-00608CB78066}")), MERIT64_DO_NOT_USE));
// Samsung's "mpeg-4 demultiplexor" can even open matroska files, amazing...
- m_transform.AddTail(new CFGFilterRegistry(GUIDFromCString(_T("{99EC0C72-4D1B-411B-AB1F-D561EE049D94}")), MERIT64_DO_NOT_USE));
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{99EC0C72-4D1B-411B-AB1F-D561EE049D94}")), MERIT64_DO_NOT_USE));
// LG Video Renderer (lgvid.ax) just crashes when trying to connect it
- m_transform.AddTail(new CFGFilterRegistry(GUIDFromCString(_T("{9F711C60-0668-11D0-94D4-0000C02BA972}")), MERIT64_DO_NOT_USE));
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{9F711C60-0668-11D0-94D4-0000C02BA972}")), MERIT64_DO_NOT_USE));
// palm demuxer crashes (even crashes graphedit when dropping an .ac3 onto it)
- m_transform.AddTail(new CFGFilterRegistry(GUIDFromCString(_T("{BE2CF8A7-08CE-4A2C-9A25-FD726A999196}")), MERIT64_DO_NOT_USE));
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{BE2CF8A7-08CE-4A2C-9A25-FD726A999196}")), MERIT64_DO_NOT_USE));
// DCDSPFilter (early versions crash mpc)
{
@@ -2233,20 +2233,20 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len)
&& GetFileVersion(buff) < 0x0001000000030000ui64)
{
- m_transform.AddTail(new CFGFilterRegistry(GUIDFromCString(clsid), MERIT64_DO_NOT_USE));
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(clsid), MERIT64_DO_NOT_USE));
}
}
/*
// NVIDIA Transport Demux crashed for someone, I could not reproduce it
- m_transform.AddTail(new CFGFilterRegistry(GUIDFromCString(_T("{735823C1-ACC4-11D3-85AC-006008376FB8}")), MERIT64_DO_NOT_USE));
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{735823C1-ACC4-11D3-85AC-006008376FB8}")), MERIT64_DO_NOT_USE));
*/
// mainconcept color space converter
- m_transform.AddTail(new CFGFilterRegistry(GUIDFromCString(_T("{272D77A0-A852-4851-ADA4-9091FEAD4C86}")), MERIT64_DO_NOT_USE));
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{272D77A0-A852-4851-ADA4-9091FEAD4C86}")), MERIT64_DO_NOT_USE));
// Block VSFilter when internal subtitle renderer will get used
if(s.fAutoloadSubtitles) {
if(s.iDSVideoRendererType == VIDRNDT_DS_VMR7RENDERLESS || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS || s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_DXR) {
- m_transform.AddTail(new CFGFilterRegistry(GUIDFromCString(_T("{9852A670-F845-491B-9BE6-EBD841B8A613}")), MERIT64_DO_NOT_USE));
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{9852A670-F845-491B-9BE6-EBD841B8A613}")), MERIT64_DO_NOT_USE));
}
}
@@ -2273,11 +2273,11 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk) if(fo->type == FilterOverride::REGISTERED)
{
- pFGF = new CFGFilterRegistry(fo->dispname, merit);
+ pFGF = DNew CFGFilterRegistry(fo->dispname, merit);
}
else if(fo->type == FilterOverride::EXTERNAL)
{
- pFGF = new CFGFilterFile(fo->clsid, fo->path, CStringW(fo->name), merit);
+ pFGF = DNew CFGFilterFile(fo->clsid, fo->path, CStringW(fo->name), merit);
}
if(pFGF)
@@ -2382,62 +2382,64 @@ CFGManagerPlayer::CFGManagerPlayer(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd) if(s.fEnableAudioSwitcher)
{
- pFGF = new CFGFilterInternal<CAudioSwitcherFilter>(L"Audio Switcher", m_armerit + 0x100);
+ pFGF = DNew CFGFilterInternal<CAudioSwitcherFilter>(L"Audio Switcher", m_armerit + 0x100);
pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
m_transform.AddTail(pFGF);
// morgan stream switcher
- m_transform.AddTail(new CFGFilterRegistry(GUIDFromCString(_T("{D3CD7858-971A-4838-ACEC-40CA5D529DC8}")), MERIT64_DO_NOT_USE));
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{D3CD7858-971A-4838-ACEC-40CA5D529DC8}")), MERIT64_DO_NOT_USE));
}
// Renderers
if(s.iDSVideoRendererType == VIDRNDT_DS_OLDRENDERER)
- m_transform.AddTail(new CFGFilterRegistry(CLSID_VideoRenderer, m_vrmerit));
+ m_transform.AddTail(DNew CFGFilterRegistry(CLSID_VideoRenderer, m_vrmerit));
else if(s.iDSVideoRendererType == VIDRNDT_DS_OVERLAYMIXER)
- m_transform.AddTail(new CFGFilterVideoRenderer(m_hWnd, CLSID_OverlayMixer, L"Overlay Mixer", m_vrmerit));
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_OverlayMixer, L"Overlay Mixer", m_vrmerit));
else if(s.iDSVideoRendererType == VIDRNDT_DS_VMR7WINDOWED)
- m_transform.AddTail(new CFGFilterVideoRenderer(m_hWnd, CLSID_VideoMixingRenderer, L"Video Mixing Render 7 (Windowed)", m_vrmerit));
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_VideoMixingRenderer, L"Video Mixing Render 7 (Windowed)", m_vrmerit));
else if(s.iDSVideoRendererType == VIDRNDT_DS_VMR9WINDOWED)
- m_transform.AddTail(new CFGFilterVideoRenderer(m_hWnd, CLSID_VideoMixingRenderer9, L"Video Mixing Render 9 (Windowed)", m_vrmerit));
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_VideoMixingRenderer9, L"Video Mixing Render 9 (Windowed)", m_vrmerit));
else if(s.iDSVideoRendererType == VIDRNDT_DS_VMR7RENDERLESS)
- m_transform.AddTail(new CFGFilterVideoRenderer(m_hWnd, CLSID_VMR7AllocatorPresenter, L"Video Mixing Render 7 (Renderless)", m_vrmerit));
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_VMR7AllocatorPresenter, L"Video Mixing Render 7 (Renderless)", m_vrmerit));
else if(s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS)
- m_transform.AddTail(new CFGFilterVideoRenderer(m_hWnd, CLSID_VMR9AllocatorPresenter, L"Video Mixing Render 9 (Renderless)", m_vrmerit));
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_VMR9AllocatorPresenter, L"Video Mixing Render 9 (Renderless)", m_vrmerit));
else if(s.iDSVideoRendererType == VIDRNDT_DS_EVR)
- m_transform.AddTail(new CFGFilterVideoRenderer(m_hWnd, CLSID_EnhancedVideoRenderer, L"Enhanced Video Renderer", m_vrmerit));
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_EnhancedVideoRenderer, L"Enhanced Video Renderer", m_vrmerit));
else if(s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM)
- m_transform.AddTail(new CFGFilterVideoRenderer(m_hWnd, CLSID_EVRAllocatorPresenter, L"Enhanced Video Renderer (custom presenter)", m_vrmerit));
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_EVRAllocatorPresenter, L"Enhanced Video Renderer (custom presenter)", m_vrmerit));
else if(s.iDSVideoRendererType == VIDRNDT_DS_DXR)
- m_transform.AddTail(new CFGFilterVideoRenderer(m_hWnd, CLSID_DXRAllocatorPresenter, L"Haali's Video Renderer", m_vrmerit));
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_DXRAllocatorPresenter, L"Haali's Video Renderer", m_vrmerit));
+ else if(s.iDSVideoRendererType == VIDRNDT_DS_MADVR)
+ m_transform.AddTail(new CFGFilterVideoRenderer(m_hWnd, CLSID_madVR, L"Madshi Video Renderer", m_vrmerit));
else if(s.iDSVideoRendererType == VIDRNDT_DS_NULL_COMP)
{
- pFGF = new CFGFilterInternal<CNullVideoRenderer>(L"Null Video Renderer (Any)", MERIT64_ABOVE_DSHOW+2);
+ pFGF = DNew CFGFilterInternal<CNullVideoRenderer>(L"Null Video Renderer (Any)", MERIT64_ABOVE_DSHOW+2);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NULL);
m_transform.AddTail(pFGF);
}
else if(s.iDSVideoRendererType == VIDRNDT_DS_NULL_UNCOMP)
{
- pFGF = new CFGFilterInternal<CNullUVideoRenderer>(L"Null Video Renderer (Uncompressed)", MERIT64_ABOVE_DSHOW+2);
+ pFGF = DNew CFGFilterInternal<CNullUVideoRenderer>(L"Null Video Renderer (Uncompressed)", MERIT64_ABOVE_DSHOW+2);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NULL);
m_transform.AddTail(pFGF);
}
if(s.AudioRendererDisplayName == AUDRNDT_NULL_COMP)
{
- pFGF = new CFGFilterInternal<CNullAudioRenderer>(AUDRNDT_NULL_COMP, MERIT64_ABOVE_DSHOW+2);
+ pFGF = DNew CFGFilterInternal<CNullAudioRenderer>(AUDRNDT_NULL_COMP, MERIT64_ABOVE_DSHOW+2);
pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
m_transform.AddTail(pFGF);
}
else if(s.AudioRendererDisplayName == AUDRNDT_NULL_UNCOMP)
{
- pFGF = new CFGFilterInternal<CNullUAudioRenderer>(AUDRNDT_NULL_UNCOMP, MERIT64_ABOVE_DSHOW+2);
+ pFGF = DNew CFGFilterInternal<CNullUAudioRenderer>(AUDRNDT_NULL_UNCOMP, MERIT64_ABOVE_DSHOW+2);
pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
m_transform.AddTail(pFGF);
}
else if(!s.AudioRendererDisplayName.IsEmpty())
{
- pFGF = new CFGFilterRegistry(s.AudioRendererDisplayName, m_armerit);
+ pFGF = DNew CFGFilterRegistry(s.AudioRendererDisplayName, m_armerit);
pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
m_transform.AddTail(pFGF);
}
@@ -2469,10 +2471,10 @@ CFGManagerDVD::CFGManagerDVD(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd) // have to avoid the old video renderer
if(!s.fXpOrBetter && s.iDSVideoRendererType != VIDRNDT_DS_OVERLAYMIXER || s.iDSVideoRendererType == VIDRNDT_DS_OLDRENDERER)
- m_transform.AddTail(new CFGFilterVideoRenderer(m_hWnd, CLSID_OverlayMixer, L"Overlay Mixer", m_vrmerit-1));
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_OverlayMixer, L"Overlay Mixer", m_vrmerit-1));
// elecard's decoder isn't suited for dvd playback (atm)
- m_transform.AddTail(new CFGFilterRegistry(GUIDFromCString(_T("{F50B3F13-19C4-11CF-AA9A-02608C9BABA2}")), MERIT64_DO_NOT_USE));
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{F50B3F13-19C4-11CF-AA9A-02608C9BABA2}")), MERIT64_DO_NOT_USE));
}
#include "..\..\decss\VobFile.h"
@@ -2558,12 +2560,12 @@ CFGManagerCapture::CFGManagerCapture(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd) {
AppSettings& s = AfxGetAppSettings();
- CFGFilter* pFGF = new CFGFilterInternal<CDeinterlacerFilter>(L"Deinterlacer", m_vrmerit + 0x100);
+ CFGFilter* pFGF = DNew CFGFilterInternal<CDeinterlacerFilter>(L"Deinterlacer", m_vrmerit + 0x100);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NULL);
m_transform.AddTail(pFGF);
// morgan stream switcher
- m_transform.AddTail(new CFGFilterRegistry(GUIDFromCString(_T("{D3CD7858-971A-4838-ACEC-40CA5D529DC8}")), MERIT64_DO_NOT_USE));
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{D3CD7858-971A-4838-ACEC-40CA5D529DC8}")), MERIT64_DO_NOT_USE));
}
//
@@ -2573,8 +2575,8 @@ CFGManagerCapture::CFGManagerCapture(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd) CFGManagerMuxer::CFGManagerMuxer(LPCTSTR pName, LPUNKNOWN pUnk)
: CFGManagerCustom(pName, pUnk)
{
- m_source.AddTail(new CFGFilterInternal<CSubtitleSourceASS>());
- m_source.AddTail(new CFGFilterInternal<CSSFSourceFilter>());
+ m_source.AddTail(DNew CFGFilterInternal<CSubtitleSourceASS>());
+ m_source.AddTail(DNew CFGFilterInternal<CSSFSourceFilter>());
}
//
diff --git a/src/apps/mplayerc/FakeFilterMapper2.cpp b/src/apps/mplayerc/FakeFilterMapper2.cpp index 4e19d5762..fffb175e2 100644 --- a/src/apps/mplayerc/FakeFilterMapper2.cpp +++ b/src/apps/mplayerc/FakeFilterMapper2.cpp @@ -264,7 +264,7 @@ HRESULT WINAPI Mine_CoCreateInstance(IN REFCLSID rclsid, IN LPUNKNOWN pUnkOuter, {
if(rclsid == CLSID_FilterMapper2)
{
- CFilterMapper2* pFM2 = new CFilterMapper2(true, false, pUnkOuter);
+ CFilterMapper2* pFM2 = DNew CFilterMapper2(true, false, pUnkOuter);
CComPtr<IUnknown> pUnk = (IUnknown*)pFM2;
return pUnk->QueryInterface(riid, ppv);
}
@@ -275,7 +275,7 @@ HRESULT WINAPI Mine_CoCreateInstance(IN REFCLSID rclsid, IN LPUNKNOWN pUnkOuter, || rclsid == CLSID_VideoRenderer || rclsid == CLSID_VideoRendererDefault
|| rclsid == CLSID_OverlayMixer)// || rclsid == CLSID_OverlayMixer2 - where is this declared?)
{
- CMacrovisionKicker* pMK = new CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
+ CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
CComPtr<IUnknown> pInner;
HRESULT hr;
@@ -570,7 +570,7 @@ STDMETHODIMP CFilterMapper2::RegisterFilter(REFCLSID clsidFilter, LPCWSTR Name, {
if(!m_path.IsEmpty())
{
- if(FilterOverride* f = new FilterOverride)
+ if(FilterOverride* f = DNew FilterOverride)
{
f->fDisabled = false;
f->type = FilterOverride::EXTERNAL;
diff --git a/src/apps/mplayerc/FileVersionInfo.cpp b/src/apps/mplayerc/FileVersionInfo.cpp index 43aa7be18..8a4646187 100644 --- a/src/apps/mplayerc/FileVersionInfo.cpp +++ b/src/apps/mplayerc/FileVersionInfo.cpp @@ -17,12 +17,6 @@ #include "stdafx.h"
#include "FileVersionInfo.h"
-#ifdef _DEBUG
-#undef THIS_FILE
-static char THIS_FILE[]=__FILE__;
-#define new DEBUG_NEW
-#endif
-
//-------------------------------------------------------------------
// CFileVersionInfo
//-------------------------------------------------------------------
@@ -84,7 +78,7 @@ BOOL CFileVersionInfo::Create(LPCTSTR lpszFileName) if (!dwFileVersionInfoSize)
return FALSE;
- LPVOID lpData = (LPVOID)new BYTE[dwFileVersionInfoSize];
+ LPVOID lpData = (LPVOID)DNew BYTE[dwFileVersionInfoSize];
if (!lpData)
return FALSE;
diff --git a/src/apps/mplayerc/FullscreenWnd.cpp b/src/apps/mplayerc/FullscreenWnd.cpp index f6ccc2d2b..55a4076c4 100644 --- a/src/apps/mplayerc/FullscreenWnd.cpp +++ b/src/apps/mplayerc/FullscreenWnd.cpp @@ -49,6 +49,16 @@ BEGIN_MESSAGE_MAP(CFullscreenWnd, CWnd) END_MESSAGE_MAP()
+LRESULT CFullscreenWnd::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch (message)
+ {
+ case WM_COMMAND :
+ m_pMainFrame->PostMessage(message, wParam, lParam);
+ break;
+ }
+ return CWnd::WindowProc(message, wParam, lParam);
+}
BOOL CFullscreenWnd::PreTranslateMessage(MSG* pMsg)
{
diff --git a/src/apps/mplayerc/FullscreenWnd.h b/src/apps/mplayerc/FullscreenWnd.h index e5f8bfd3f..f7e7e0b28 100644 --- a/src/apps/mplayerc/FullscreenWnd.h +++ b/src/apps/mplayerc/FullscreenWnd.h @@ -41,6 +41,8 @@ protected: virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
+
CMainFrame* m_pMainFrame;
HCURSOR m_hCursor;
diff --git a/src/apps/mplayerc/IPinHook.cpp b/src/apps/mplayerc/IPinHook.cpp index c2b156a68..354db7100 100644 --- a/src/apps/mplayerc/IPinHook.cpp +++ b/src/apps/mplayerc/IPinHook.cpp @@ -280,7 +280,7 @@ static void LOG_TOFILE(LPCTSTR FileName, LPCTSTR fmt, ...) va_list args;
va_start(args, fmt);
int nCount = _vsctprintf(fmt, args) + 1;
- if(TCHAR* buff = new TCHAR[nCount])
+ if(TCHAR* buff = DNew TCHAR[nCount])
{
FILE* f;
_vstprintf_s(buff, nCount, fmt, args);
@@ -1366,7 +1366,7 @@ static HRESULT STDMETHODCALLTYPE CreateVideoDecoderMine( #ifdef _DEBUG
if ((Guid == DXVA2_ModeH264_E) || (Guid == DXVA2_ModeVC1_D) || (Guid == DXVA_Intel_H264_ClearVideo))
{
- *ppDecode = new CFakeDirectXVideoDecoder (NULL, *ppDecode);
+ *ppDecode = DNew CFakeDirectXVideoDecoder (NULL, *ppDecode);
(*ppDecode)->AddRef();
}
diff --git a/src/apps/mplayerc/Ifo.cpp b/src/apps/mplayerc/Ifo.cpp index 88c76c803..f0868960f 100644 --- a/src/apps/mplayerc/Ifo.cpp +++ b/src/apps/mplayerc/Ifo.cpp @@ -194,7 +194,7 @@ bool CIfo::OpenFile (LPCTSTR strFile) if (hFile != INVALID_HANDLE_VALUE)
{
DWORD dwSize = GetFileSize (hFile, NULL);
- m_pBuffer = new BYTE [dwSize];
+ m_pBuffer = DNew BYTE [dwSize];
ReadFile (hFile, m_pBuffer, dwSize, &m_dwSize, NULL);
CloseHandle (hFile);
diff --git a/src/apps/mplayerc/LineNumberEdit.cpp b/src/apps/mplayerc/LineNumberEdit.cpp index 563bd4a15..9566e2cdd 100644 --- a/src/apps/mplayerc/LineNumberEdit.cpp +++ b/src/apps/mplayerc/LineNumberEdit.cpp @@ -89,12 +89,6 @@ #include "stdafx.h"
#include "LineNumberEdit.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
// Registered message to allow selection of complete
// lines by clicking the line number
UINT urm_SELECTLINE = ::RegisterWindowMessage( _T("_LINE_NUMBER_EDIT_SELECTLINE_") );
diff --git a/src/apps/mplayerc/MainFrm.cpp b/src/apps/mplayerc/MainFrm.cpp index 9458a1bc3..750c692b1 100644 --- a/src/apps/mplayerc/MainFrm.cpp +++ b/src/apps/mplayerc/MainFrm.cpp @@ -140,13 +140,6 @@ bool m_PlayListBarVisible = false; bool m_Change_Monitor = false;
-/*
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-*/
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
@@ -319,8 +312,52 @@ BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) ON_COMMAND(ID_VIEW_TEARING_TEST, OnViewTearingTest)
ON_UPDATE_COMMAND_UI(ID_VIEW_DISPLAYSTATS, OnUpdateViewDisplayStats)
ON_COMMAND(ID_VIEW_DISPLAYSTATS, OnViewDisplayStats)
+ ON_COMMAND(ID_VIEW_DISPLAYSTATS_SC, OnViewDisplayStatsSC)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_FULLSCREENGUISUPPORT, OnUpdateViewFullscreenGUISupport)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_HIGHCOLORRESOLUTION, OnUpdateViewHighColorResolution)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_ENABLEFRAMETIMECORRECTION, OnUpdateViewEnableFrameTimeCorrection)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNC, OnUpdateViewVSync)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNCOFFSET, OnUpdateViewVSyncOffset)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNCACCURATE, OnUpdateViewVSyncAccurate)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_EVROUTPUTRANGE_0_255, OnUpdateViewEVROutputRange)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_EVROUTPUTRANGE_16_235, OnUpdateViewEVROutputRange)
+
+ ON_UPDATE_COMMAND_UI(ID_VIEW_FLUSHGPU_BEFOREVSYNC, OnUpdateViewFlushGPU)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_FLUSHGPU_AFTERPRESENT, OnUpdateViewFlushGPU)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_FLUSHGPU_WAIT, OnUpdateViewFlushGPU)
+
+ ON_UPDATE_COMMAND_UI(ID_VIEW_D3DFULLSCREEN, OnUpdateViewD3DFullscreen)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_DISABLEDESKTOPCOMPOSITION, OnUpdateViewDisableDesktopComposition)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_ALTERNATIVEVSYNC, OnUpdateViewAlternativeVSync)
+
+
+ ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNCOFFSET_INCREASE, OnUpdateViewVSyncOffsetIncrease)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNCOFFSET_DECREASE, OnUpdateViewVSyncOffsetDecrease)
+ ON_COMMAND(ID_VIEW_FULLSCREENGUISUPPORT, OnViewFullscreenGUISupport)
+ ON_COMMAND(ID_VIEW_HIGHCOLORRESOLUTION, OnViewHighColorResolution)
+ ON_COMMAND(ID_VIEW_ENABLEFRAMETIMECORRECTION, OnViewEnableFrameTimeCorrection)
+ ON_COMMAND(ID_VIEW_VSYNC, OnViewVSync)
+ ON_COMMAND(ID_VIEW_VSYNCACCURATE, OnViewVSyncAccurate)
+
+ ON_COMMAND(ID_VIEW_EVROUTPUTRANGE_0_255, OnViewEVROutputRange_0_255)
+ ON_COMMAND(ID_VIEW_EVROUTPUTRANGE_16_235, OnViewEVROutputRange_16_235)
+
+ ON_COMMAND(ID_VIEW_FLUSHGPU_BEFOREVSYNC, OnViewFlushGPUBeforeVSync)
+ ON_COMMAND(ID_VIEW_FLUSHGPU_AFTERPRESENT, OnViewFlushGPUAfterVSync)
+ ON_COMMAND(ID_VIEW_FLUSHGPU_WAIT, OnViewFlushGPUWait)
+
+ ON_COMMAND(ID_VIEW_D3DFULLSCREEN, OnViewD3DFullScreen)
+ ON_COMMAND(ID_VIEW_DISABLEDESKTOPCOMPOSITION, OnViewDisableDesktopComposition)
+ ON_COMMAND(ID_VIEW_ALTERNATIVEVSYNC, OnViewAlternativeVSync)
+ ON_COMMAND(ID_VIEW_RESET_DEFAULT, OnViewResetDefault)
+ ON_COMMAND(ID_VIEW_RESET_OPTIMAL, OnViewResetOptimal)
+
+ ON_COMMAND(ID_VIEW_VSYNCOFFSET_INCREASE, OnViewVSyncOffsetIncrease)
+ ON_COMMAND(ID_VIEW_VSYNCOFFSET_DECREASE, OnViewVSyncOffsetDecrease)
ON_UPDATE_COMMAND_UI(ID_SHADER_TOGGLE, OnUpdateShaderToggle)
ON_COMMAND(ID_SHADER_TOGGLE, OnShaderToggle)
+ ON_UPDATE_COMMAND_UI(ID_SHADER_TOGGLESCREENSPACE, OnUpdateShaderToggleScreenSpace)
+ ON_COMMAND(ID_SHADER_TOGGLESCREENSPACE, OnShaderToggleScreenSpace)
ON_UPDATE_COMMAND_UI(ID_VIEW_REMAINING_TIME, OnUpdateViewRemainingTime)
ON_COMMAND(ID_VIEW_REMAINING_TIME, OnViewRemainingTime)
ON_COMMAND(ID_D3DFULLSCREEN_TOGGLE, OnD3DFullscreenToggle)
@@ -442,7 +479,9 @@ CMainFrame::CMainFrame() : m_lSubtitleShift(0),
m_bToggleShader(false),
m_nStepForwardCount(0),
- m_rtStepForwardStart(0)
+ m_rtStepForwardStart(0),
+ m_bToggleShaderScreenSpace(false),
+ m_bInOptions(false)
{
m_Lcd.SetVolumeRange(1, 100);
}
@@ -483,7 +522,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) return -1; // fail to create
}
- m_pFullscreenWnd = new CFullscreenWnd(this);
+ m_pFullscreenWnd = DNew CFullscreenWnd(this);
m_bars.AddTail(&m_wndSeekBar);
m_bars.AddTail(&m_wndToolBar);
@@ -551,16 +590,30 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) StartWebServer(s.nWebServerPort);
// Casimir666 : rechargement des Shaders
- CString strList = AfxGetAppSettings().strShaderList;
- CString strRes;
- int curPos= 0;
-
- strRes = strList.Tokenize (_T("|"), curPos);
- while (strRes != _T(""))
{
- m_shaderlabels.AddTail (strRes);
- strRes = strList.Tokenize(_T("|"),curPos);
- };
+ CString strList = AfxGetAppSettings().strShaderList;
+ CString strRes;
+ int curPos= 0;
+
+ strRes = strList.Tokenize (_T("|"), curPos);
+ while (strRes != _T(""))
+ {
+ m_shaderlabels.AddTail (strRes);
+ strRes = strList.Tokenize(_T("|"),curPos);
+ }
+ }
+ {
+ CString strList = AfxGetAppSettings().strShaderListScreenSpace;
+ CString strRes;
+ int curPos= 0;
+
+ strRes = strList.Tokenize (_T("|"), curPos);
+ while (strRes != _T(""))
+ {
+ m_shaderlabelsScreenSpace.AddTail (strRes);
+ strRes = strList.Tokenize(_T("|"),curPos);
+ }
+ }
m_strTitle.Format (L"%s - v%s", ResStr(IDR_MAINFRAME), AfxGetMyApp()->m_strVersion);
SetWindowText(m_strTitle);
@@ -599,16 +652,30 @@ void CMainFrame::OnDestroy() void CMainFrame::OnClose()
{
// Casimir666 : sauvegarde de la liste des shaders
- POSITION pos;
- CString strList = "";
-
- pos = m_shaderlabels.GetHeadPosition();
- while(pos)
{
- strList += m_shaderlabels.GetAt (pos) + "|";
- m_dockingbars.GetNext(pos);
+ POSITION pos;
+ CString strList = "";
+
+ pos = m_shaderlabels.GetHeadPosition();
+ while(pos)
+ {
+ strList += m_shaderlabels.GetAt (pos) + "|";
+ m_dockingbars.GetNext(pos);
+ }
+ AfxGetAppSettings().strShaderList = strList;
+ }
+ {
+ POSITION pos;
+ CString strList = "";
+
+ pos = m_shaderlabelsScreenSpace.GetHeadPosition();
+ while(pos)
+ {
+ strList += m_shaderlabelsScreenSpace.GetAt (pos) + "|";
+ m_dockingbars.GetNext(pos);
+ }
+ AfxGetAppSettings().strShaderListScreenSpace = strList;
}
- AfxGetAppSettings().strShaderList = strList;
m_wndPlaylistBar.SavePlaylist();
@@ -810,7 +877,7 @@ LRESULT CMainFrame::OnNotifyIcon(WPARAM wParam, LPARAM lParam) POINT p;
GetCursorPos(&p);
SetForegroundWindow();
- m_popupmain.GetSubMenu(0)->TrackPopupMenu(TPM_RIGHTBUTTON|TPM_NOANIMATION, p.x, p.y, this);
+ m_popupmain.GetSubMenu(0)->TrackPopupMenu(TPM_RIGHTBUTTON|TPM_NOANIMATION, p.x, p.y, GetModalParent());
PostMessage(WM_NULL);
break;
}
@@ -1447,7 +1514,8 @@ void CMainFrame::OnTimer(UINT_PTR nIDEvent) m_wndSubresyncBar.SetTime(pos);
- if(m_pCAP && GetMediaState() == State_Paused) m_pCAP->Paint(true);
+ if(m_pCAP && GetMediaState() == State_Paused)
+ m_pCAP->Paint(false);
}
else if(nIDEvent == TIMER_FULLSCREENCONTROLBARHIDER)
{
@@ -1477,7 +1545,8 @@ void CMainFrame::OnTimer(UINT_PTR nIDEvent) if (m_pFullscreenWnd->IsWindow())
{
TRACE ("==> HIDE!\n");
- m_pFullscreenWnd->ShowCursor(false);
+ if (!m_bInOptions)
+ m_pFullscreenWnd->ShowCursor(false);
KillTimer(TIMER_FULLSCREENMOUSEHIDER);
}
else
@@ -2189,7 +2258,9 @@ BOOL CMainFrame::OnButton(UINT id, UINT nFlags, CPoint point) CRect r;
if (m_pFullscreenWnd->IsWindow())
+ {
m_pFullscreenWnd->GetClientRect(r);
+ }
else
{
m_wndView.GetClientRect(r);
@@ -2726,6 +2797,7 @@ BOOL CMainFrame::OnMenu(CMenu* pMenu) KillTimer(TIMER_FULLSCREENMOUSEHIDER);
m_fHideCursor = false;
+ CWnd *pModalParent = GetModalParent();
CPoint point;
GetCursorPos(&point);
@@ -2736,7 +2808,7 @@ BOOL CMainFrame::OnMenu(CMenu* pMenu) void CMainFrame::OnMenuPlayerShort()
{
- if(IsCaptionMenuHidden())
+ if(IsCaptionMenuHidden() || m_pFullscreenWnd->IsWindow())
{
OnMenu(m_popupmain.GetSubMenu(0));
}
@@ -3358,10 +3430,9 @@ void CMainFrame::OnFileOpenQuick() CString filter;
CAtlArray<CString> mask;
AfxGetAppSettings().Formats.GetFilter(filter, mask);
-
COpenFileDlg fd(mask, true, NULL, NULL,
OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ALLOWMULTISELECT|OFN_ENABLEINCLUDENOTIFY,
- filter, this);
+ filter, GetModalParent());
if(fd.DoModal() != IDOK) return;
CAtlList<CString> fns;
@@ -3525,7 +3596,7 @@ BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCDS) SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
fSetForegroundWindow = true;
- CAutoPtr<OpenDVDData> p(new OpenDVDData());
+ CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
if(p) {p->path = s.slFiles.GetHead(); p->subs.AddTailList(&s.slSubs);}
OpenMedia(p);
}
@@ -3625,7 +3696,7 @@ void CMainFrame::OnFileOpendvd() ShowWindow(SW_SHOW);
- CAutoPtr<OpenDVDData> p(new OpenDVDData());
+ CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
if(p)
{
AppSettings& s = AfxGetAppSettings();
@@ -3668,7 +3739,7 @@ void CMainFrame::OnFileOpendvd() }
else
{
- CAutoPtr<OpenDVDData> p(new OpenDVDData());
+ CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
p->path = path;
p->path.Replace('/', '\\');
if(p->path[p->path.GetLength()-1] != '\\') p->path += '\\';
@@ -3693,7 +3764,7 @@ void CMainFrame::OnFileOpendevice() m_wndPlaylistBar.Empty();
- CAutoPtr<OpenDeviceData> p(new OpenDeviceData());
+ CAutoPtr<OpenDeviceData> p(DNew OpenDeviceData());
if(p) {p->DisplayName[0] = capdlg.m_vidstr; p->DisplayName[1] = capdlg.m_audstr;}
OpenMedia(p);
}
@@ -3791,7 +3862,7 @@ void CMainFrame::OnFileSaveAs() CFileDialog fd(FALSE, 0, out,
OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST,
- ResStr(IDS_MAINFRM_48), this, 0);
+ ResStr(IDS_MAINFRM_48), GetModalParent(), 0);
if(fd.DoModal() != IDOK || !in.CompareNoCase(fd.GetPathName())) return;
CPath p(fd.GetPathName());
@@ -3865,7 +3936,7 @@ bool CMainFrame::GetDIB(BYTE** ppData, long& size, bool fSilent) hr = m_pCAP->GetDIB(NULL, (DWORD*)&size);
if(FAILED(hr)) {errmsg.Format(ResStr(IDS_MAINFRM_49), hr); break;}
- if(!(*ppData = new BYTE[size])) return false;
+ if(!(*ppData = DNew BYTE[size])) return false;
hr = m_pCAP->GetDIB(*ppData, (DWORD*)&size);
// if(FAILED(hr)) {errmsg.Format(_T("GetDIB failed, hr = %08x"), hr); break;}
@@ -3895,7 +3966,7 @@ bool CMainFrame::GetDIB(BYTE** ppData, long& size, bool fSilent) if(FAILED(hr) || dwSize == 0) {errmsg.Format(ResStr(IDS_MAINFRM_51), hr); break;}
size = (long)dwSize+sizeof(BITMAPINFOHEADER);
- if(!(*ppData = new BYTE[size])) return false;
+ if(!(*ppData = DNew BYTE[size])) return false;
memcpy_s (*ppData, size, &bih, sizeof(BITMAPINFOHEADER));
memcpy_s (*ppData+sizeof(BITMAPINFOHEADER), size-sizeof(BITMAPINFOHEADER), pDib, dwSize);
CoTaskMemFree (pDib);
@@ -3905,7 +3976,7 @@ bool CMainFrame::GetDIB(BYTE** ppData, long& size, bool fSilent) hr = pBV->GetCurrentImage(&size, NULL);
if(FAILED(hr) || size == 0) {errmsg.Format(ResStr(IDS_MAINFRM_51), hr); break;}
- if(!(*ppData = new BYTE[size])) return false;
+ if(!(*ppData = DNew BYTE[size])) return false;
hr = pBV->GetCurrentImage(&size, (long*)*ppData);
if(FAILED(hr)) {errmsg.Format(ResStr(IDS_MAINFRM_51), hr); break;}
@@ -3957,7 +4028,7 @@ void CMainFrame::SaveDIB(LPCTSTR fn, BYTE* pData, long size) if(bi->bmiHeader.biBitCount <= 8)
{
if(bi->bmiHeader.biClrUsed) bfh.bfOffBits += bi->bmiHeader.biClrUsed * sizeof(bi->bmiColors[0]);
- else bfh.bfOffBits += (1 << bi->bmiHeader.biBitCount) * sizeof(bi->bmiColors[0]);
+ else bfh.bfOffBits += (1 << bi->bmiHeader.biBitCount) * DWORD(sizeof(bi->bmiColors[0]));
}
fwrite(&bfh, 1, sizeof(bfh), f);
@@ -3990,7 +4061,7 @@ void CMainFrame::SaveDIB(LPCTSTR fn, BYTE* pData, long size) if(bi->bmiHeader.biBitCount <= 8)
{
if(bi->bmiHeader.biClrUsed) bfh.bfOffBits += bi->bmiHeader.biClrUsed * sizeof(bi->bmiColors[0]);
- else bfh.bfOffBits += (1 << bi->bmiHeader.biBitCount) * sizeof(bi->bmiColors[0]);
+ else bfh.bfOffBits += (1 << bi->bmiHeader.biBitCount) * DWORD(sizeof(bi->bmiColors[0]));
}
pbmfh = (LPBITMAPFILEHEADER)&bfh;
pbits = &pData[pbmfh->bfOffBits-sizeof(bfh)];
@@ -4183,7 +4254,7 @@ void CMainFrame::SaveThumbnails(LPCTSTR fn) CRenderedTextSubtitle rts(&csSubLock);
rts.CreateDefaultStyle(0);
rts.m_dstScreenSize.SetSize(width, height);
- STSStyle* style = new STSStyle();
+ STSStyle* style = DNew STSStyle();
style->marginRect.SetRectEmpty();
rts.AddStyle(_T("thumbs"), style);
@@ -4266,7 +4337,7 @@ void CMainFrame::SaveThumbnails(LPCTSTR fn) CRenderedTextSubtitle rts(&csSubLock);
rts.CreateDefaultStyle(0);
rts.m_dstScreenSize.SetSize(width, height);
- STSStyle* style = new STSStyle();
+ STSStyle* style = DNew STSStyle();
style->marginRect.SetRect(margin*2, margin*2, margin*2, height-infoheight-margin);
rts.AddStyle(_T("thumbs"), style);
@@ -4380,7 +4451,7 @@ void CMainFrame::OnFileSaveImage() CFileDialog fd(FALSE, 0, (LPCTSTR)psrc,
OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST,
- _T("Bitmaps (*.bmp)|*.bmp|Jpeg (*.jpg)|*.jpg|Png (*.png)|*.png||"), this, 0);
+ _T("Bitmaps (*.bmp)|*.bmp|Jpeg (*.jpg)|*.jpg|Png (*.png)|*.png||"), GetModalParent(), 0);
if(s.SnapShotExt == _T(".bmp")) fd.m_pOFN->nFilterIndex = 1;
else if(s.SnapShotExt == _T(".jpg")) fd.m_pOFN->nFilterIndex = 2;
@@ -4457,7 +4528,7 @@ void CMainFrame::OnFileSaveThumbnails() CSaveThumbnailsDialog fd(
s.ThumbRows, s.ThumbCols, s.ThumbWidth,
0, (LPCTSTR)psrc,
- _T("Bitmaps (*.bmp)|*.bmp|Jpeg (*.jpg)|*.jpg|Png (*.png)|*.png||"), this);
+ _T("Bitmaps (*.bmp)|*.bmp|Jpeg (*.jpg)|*.jpg|Png (*.png)|*.png||"), GetModalParent());
if(s.SnapShotExt == _T(".bmp")) fd.m_pOFN->nFilterIndex = 1;
else if(s.SnapShotExt == _T(".jpg")) fd.m_pOFN->nFilterIndex = 2;
@@ -4517,7 +4588,7 @@ void CMainFrame::OnFileLoadsubtitle() CFileDialog fd(TRUE, NULL, NULL,
OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY,
- szFilter, this, 0);
+ szFilter, GetModalParent(), 0);
if(fd.DoModal() != IDOK) return;
@@ -4551,7 +4622,7 @@ void CMainFrame::OnFileSavesubtitle() CFileDialog fd(FALSE, NULL, NULL,
OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST,
- _T("VobSub (*.idx, *.sub)|*.idx;*.sub||"), this, 0);
+ _T("VobSub (*.idx, *.sub)|*.idx;*.sub||"), GetModalParent(), 0);
if(fd.DoModal() == IDOK)
{
@@ -4574,7 +4645,7 @@ void CMainFrame::OnFileSavesubtitle() filter += _T("Advanced Sub Station Alpha (*.ass)|*.ass|");
filter += _T("|");
- CSaveTextFileDialog fd(pRTS->m_encoding, NULL, NULL, filter, this);
+ CSaveTextFileDialog fd(pRTS->m_encoding, NULL, NULL, filter, GetModalParent());
if(fd.DoModal() == IDOK)
{
@@ -4683,7 +4754,7 @@ void CMainFrame::OnFileISDBDownload() else if(param == "" && value == "end") break;
}
- CSubtitleDlDlg dlg(movies, this);
+ CSubtitleDlDlg dlg(movies, GetModalParent());
if(IDOK == dlg.DoModal())
{
if(dlg.m_fReplaceSubs)
@@ -4702,7 +4773,7 @@ void CMainFrame::OnFileISDBDownload() if(OpenUrl(is, CString(url+args), str))
{
- CAutoPtr<CRenderedTextSubtitle> pRTS(new CRenderedTextSubtitle(&m_csSubLock));
+ CAutoPtr<CRenderedTextSubtitle> pRTS(DNew CRenderedTextSubtitle(&m_csSubLock));
if(pRTS && pRTS->Open((BYTE*)(LPCSTR)str, str.GetLength(), DEFAULT_CHARSET, CString(s.name)) && pRTS->GetStreamCount() > 0)
{
CComPtr<ISubStream> pSubStream = pRTS.Detach();
@@ -4730,7 +4801,7 @@ void CMainFrame::OnUpdateFileISDBDownload(CCmdUI *pCmdUI) void CMainFrame::OnFileProperties()
{
- CPPageFileInfoSheet m_fileinfo(m_wndPlaylistBar.GetCur(), this);
+ CPPageFileInfoSheet m_fileinfo(m_wndPlaylistBar.GetCur(), this, GetModalParent());
m_fileinfo.DoModal();
}
@@ -4769,6 +4840,313 @@ void CMainFrame::OnViewDisplayStats() AfxGetMyApp()->m_fDisplayStats = ! AfxGetMyApp()->m_fDisplayStats;
}
+void CMainFrame::OnViewDisplayStatsSC()
+{
+ ++AfxGetMyApp()->m_fDisplayStats;
+ if (AfxGetMyApp()->m_fDisplayStats > 3)
+ AfxGetMyApp()->m_fDisplayStats = 0;
+}
+
+void CMainFrame::OnUpdateViewVSync(CCmdUI* pCmdUI)
+{
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+
+ pCmdUI->Enable (supported);
+ pCmdUI->SetCheck (!supported || (s.m_RenderSettings.iVMR9VSync));
+}
+
+void CMainFrame::OnUpdateViewVSyncOffset(CCmdUI* pCmdUI)
+{
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) && s.m_RenderSettings.fVMR9AlterativeVSync;
+
+ pCmdUI->Enable (false);
+ CString Temp;
+ Temp.Format(L"%d", s.m_RenderSettings.iVMR9VSyncOffset);
+ pCmdUI->SetText(Temp);
+}
+
+void CMainFrame::OnUpdateViewVSyncAccurate(CCmdUI* pCmdUI)
+{
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+
+ pCmdUI->Enable (supported);
+ pCmdUI->SetCheck(s.m_RenderSettings.iVMR9VSyncAccurate);
+}
+
+void CMainFrame::OnUpdateViewEVROutputRange(CCmdUI* pCmdUI)
+{
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+
+ pCmdUI->Enable (supported);
+
+ if (pCmdUI->m_nID == ID_VIEW_EVROUTPUTRANGE_0_255)
+ pCmdUI->SetCheck(s.m_RenderSettings.iEVROutputRange == 0);
+ else if (pCmdUI->m_nID == ID_VIEW_EVROUTPUTRANGE_16_235)
+ pCmdUI->SetCheck(s.m_RenderSettings.iEVROutputRange == 1);
+}
+
+
+void CMainFrame::OnUpdateViewFlushGPU(CCmdUI* pCmdUI)
+{
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+
+ pCmdUI->Enable (supported);
+
+ if (pCmdUI->m_nID == ID_VIEW_FLUSHGPU_BEFOREVSYNC)
+ pCmdUI->SetCheck(s.m_RenderSettings.iVMRFlushGPUBeforeVSync != 0);
+ else if (pCmdUI->m_nID == ID_VIEW_FLUSHGPU_AFTERPRESENT)
+ pCmdUI->SetCheck(s.m_RenderSettings.iVMRFlushGPUAfterPresent != 0);
+ else if (pCmdUI->m_nID == ID_VIEW_FLUSHGPU_WAIT)
+ pCmdUI->SetCheck(s.m_RenderSettings.iVMRFlushGPUWait != 0);
+
+}
+
+void CMainFrame::OnUpdateViewD3DFullscreen(CCmdUI* pCmdUI)
+{
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+
+ pCmdUI->Enable (supported);
+ pCmdUI->SetCheck(s.fD3DFullscreen);
+}
+
+void CMainFrame::OnUpdateViewDisableDesktopComposition(CCmdUI* pCmdUI)
+{
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+
+ pCmdUI->Enable (supported);
+ pCmdUI->SetCheck(s.m_RenderSettings.iVMRDisableDesktopComposition);
+}
+
+void CMainFrame::OnUpdateViewAlternativeVSync(CCmdUI* pCmdUI)
+{
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+
+ pCmdUI->Enable (supported);
+ pCmdUI->SetCheck(s.m_RenderSettings.fVMR9AlterativeVSync);
+}
+
+
+void CMainFrame::OnUpdateViewFullscreenGUISupport(CCmdUI* pCmdUI)
+{
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+
+ pCmdUI->Enable (supported);
+ pCmdUI->SetCheck(s.m_RenderSettings.iVMR9FullscreenGUISupport);
+}
+
+void CMainFrame::OnUpdateViewHighColorResolution(CCmdUI* pCmdUI)
+{
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+
+ pCmdUI->Enable (supported);
+ pCmdUI->SetCheck(s.m_RenderSettings.iEVRHighColorResolution);
+}
+
+void CMainFrame::OnUpdateViewEnableFrameTimeCorrection(CCmdUI* pCmdUI)
+{
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+
+ pCmdUI->Enable (supported);
+ pCmdUI->SetCheck(s.m_RenderSettings.iEVREnableFrameTimeCorrection);
+}
+
+void CMainFrame::OnUpdateViewVSyncOffsetIncrease(CCmdUI* pCmdUI)
+{
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) && s.m_RenderSettings.fVMR9AlterativeVSync;
+
+ pCmdUI->Enable (supported);
+}
+
+void CMainFrame::OnUpdateViewVSyncOffsetDecrease(CCmdUI* pCmdUI)
+{
+ AppSettings& s = AfxGetAppSettings();
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) && s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) && s.m_RenderSettings.fVMR9AlterativeVSync;
+
+ pCmdUI->Enable (supported);
+}
+
+void CMainFrame::OnViewVSync()
+{
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iVMR9VSync = !s.m_RenderSettings.iVMR9VSync;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"VSync: %s", s.m_RenderSettings.iVMR9VSync? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
+}
+
+void CMainFrame::OnViewVSyncAccurate()
+{
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iVMR9VSyncAccurate = !s.m_RenderSettings.iVMR9VSyncAccurate;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Accurate VSync: %s", s.m_RenderSettings.iVMR9VSyncAccurate? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
+}
+
+void CMainFrame::OnViewEVROutputRange_0_255()
+{
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iEVROutputRange = 0;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Output Range: 0 - 255");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
+}
+
+void CMainFrame::OnViewEVROutputRange_16_235()
+{
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iEVROutputRange = 1;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Output Range: 16 - 235");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
+}
+
+void CMainFrame::OnViewFlushGPUBeforeVSync()
+{
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iVMRFlushGPUBeforeVSync = !s.m_RenderSettings.iVMRFlushGPUBeforeVSync;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Flush GPU before VSync: %s", s.m_RenderSettings.iVMRFlushGPUBeforeVSync? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
+}
+
+void CMainFrame::OnViewFlushGPUAfterVSync()
+{
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iVMRFlushGPUAfterPresent = !s.m_RenderSettings.iVMRFlushGPUAfterPresent;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Flush GPU after Present: %s", s.m_RenderSettings.iVMRFlushGPUAfterPresent? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
+}
+
+void CMainFrame::OnViewFlushGPUWait()
+{
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iVMRFlushGPUWait = !s.m_RenderSettings.iVMRFlushGPUWait;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Wait for GPU Flush: %s", s.m_RenderSettings.iVMRFlushGPUWait? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
+}
+
+void CMainFrame::OnViewD3DFullScreen()
+{
+ AppSettings& s = AfxGetAppSettings();
+ s.fD3DFullscreen = !s.fD3DFullscreen;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"D3D Fullscreen (Requires restart): %s", s.fD3DFullscreen? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
+}
+
+void CMainFrame::OnViewDisableDesktopComposition()
+{
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iVMRDisableDesktopComposition = !s.m_RenderSettings.iVMRDisableDesktopComposition;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Disable desktop composition: %s", s.m_RenderSettings.iVMRDisableDesktopComposition? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
+}
+
+void CMainFrame::OnViewAlternativeVSync()
+{
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.fVMR9AlterativeVSync = !s.m_RenderSettings.fVMR9AlterativeVSync;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Alternative VSync: %s", s.m_RenderSettings.fVMR9AlterativeVSync? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
+}
+
+void CMainFrame::OnViewResetDefault()
+{
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.SetDefault();
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Renderer settings reset to default");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
+}
+
+void CMainFrame::OnViewResetOptimal()
+{
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.SetOptimal();
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Renderer settings reset to optimal");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
+}
+
+void CMainFrame::OnViewFullscreenGUISupport()
+{
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iVMR9FullscreenGUISupport = !s.m_RenderSettings.iVMR9FullscreenGUISupport;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"D3D Fullscreen GUI Support: %s", s.m_RenderSettings.iVMR9FullscreenGUISupport? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
+}
+
+void CMainFrame::OnViewHighColorResolution()
+{
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iEVRHighColorResolution = !s.m_RenderSettings.iEVRHighColorResolution;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"10 bit RGB: %s", s.m_RenderSettings.iEVRHighColorResolution? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
+}
+
+void CMainFrame::OnViewEnableFrameTimeCorrection()
+{
+ AppSettings& s = AfxGetAppSettings();
+ s.m_RenderSettings.iEVREnableFrameTimeCorrection = !s.m_RenderSettings.iEVREnableFrameTimeCorrection;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"Frame Time Correction: %s", s.m_RenderSettings.iEVREnableFrameTimeCorrection? L"On":L"Off");
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
+}
+
+void CMainFrame::OnViewVSyncOffsetIncrease()
+{
+ AppSettings& s = AfxGetAppSettings();
+ ++s.m_RenderSettings.iVMR9VSyncOffset;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"VSync Offset: %d", s.m_RenderSettings.iVMR9VSyncOffset);
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
+}
+
+void CMainFrame::OnViewVSyncOffsetDecrease()
+{
+ AppSettings& s = AfxGetAppSettings();
+ --s.m_RenderSettings.iVMR9VSyncOffset;
+ s.UpdateData(true);
+ CString Format;
+ Format.Format(L"VSync Offset: %d", s.m_RenderSettings.iVMR9VSyncOffset);
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, Format);
+}
+
void CMainFrame::OnUpdateViewRemainingTime(CCmdUI* pCmdUI)
{
AppSettings& s = AfxGetAppSettings();
@@ -4788,20 +5166,44 @@ void CMainFrame::OnUpdateShaderToggle(CCmdUI* pCmdUI) pCmdUI->SetCheck (m_bToggleShader);
}
+void CMainFrame::OnUpdateShaderToggleScreenSpace(CCmdUI* pCmdUI)
+{
+ pCmdUI->Enable (TRUE);
+ pCmdUI->SetCheck (m_bToggleShaderScreenSpace);
+}
+
void CMainFrame::OnShaderToggle()
{
- if (m_bToggleShader)
+ m_bToggleShader = !m_bToggleShader;
+ if (!m_bToggleShader)
{
SetShaders();
m_OSD.DisplayMessage (OSD_TOPRIGHT, ResStr(IDS_MAINFRM_65));
}
else
{
- if (m_pCAP) m_pCAP->SetPixelShader(NULL, NULL);
+ if (m_pCAP)
+ m_pCAP->SetPixelShader(NULL, NULL);
m_OSD.DisplayMessage (OSD_TOPRIGHT, ResStr(IDS_MAINFRM_66));
}
- m_bToggleShader = !m_bToggleShader;
+}
+
+void CMainFrame::OnShaderToggleScreenSpace()
+{
+ m_bToggleShaderScreenSpace = !m_bToggleShaderScreenSpace;
+ if (!m_bToggleShaderScreenSpace)
+ {
+ SetShaders();
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, ResStr(IDS_MAINFRM_PPONSCR));
+ }
+ else
+ {
+ if (m_pCAP2)
+ m_pCAP2->SetPixelShader2(NULL, NULL, true);
+ m_OSD.DisplayMessage (OSD_TOPRIGHT, ResStr(IDS_MAINFRM_PPOFFSCR));
+ }
+
}
void CMainFrame::OnD3DFullscreenToggle()
@@ -5945,7 +6347,7 @@ void CMainFrame::OnPlayFilters(UINT nID) CComPtr<IUnknown> pUnk = m_pparray[nID - ID_FILTERS_SUBITEM_START];
- CComPropertySheet ps(ResStr(IDS_PROPSHEET_PROPERTIES), this);
+ CComPropertySheet ps(ResStr(IDS_PROPSHEET_PROPERTIES), GetModalParent());
if(CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk)
{
@@ -5955,7 +6357,7 @@ void CMainFrame::OnPlayFilters(UINT nID) if(CComQIPtr<IBaseFilter> pBF = pUnk)
{
HRESULT hr;
- CComPtr<IPropertyPage> pPP = new CInternalPropertyPageTempl<CPinInfoWnd>(NULL, &hr);
+ CComPtr<IPropertyPage> pPP = DNew CInternalPropertyPageTempl<CPinInfoWnd>(NULL, &hr);
ps.AddPage(pPP, pBF);
}
@@ -5971,9 +6373,21 @@ void CMainFrame::OnUpdatePlayFilters(CCmdUI* pCmdUI) pCmdUI->Enable(!m_fCapturing);
}
+enum
+{
+ ID_SHADERS_OFF = ID_SHADERS_START,
+ ID_SHADERS_COMBINE,
+ ID_SHADERS_EDIT,
+ ID_SHADERS_STARTSCR,
+ ID_SHADERS_OFFSCR = ID_SHADERS_STARTSCR,
+ ID_SHADERS_COMBINESCR,
+ ID_SHADERS_ENDSCR,
+ ID_SHADERS_DYNAMIC = ID_SHADERS_ENDSCR,
+};
+
void CMainFrame::OnPlayShaders(UINT nID)
{
- if(nID == ID_SHADERS_START+2)
+ if(nID == ID_SHADERS_EDIT)
{
ShowControlBar(&m_wndShaderEditorBar, TRUE, TRUE);
return;
@@ -5981,16 +6395,25 @@ void CMainFrame::OnPlayShaders(UINT nID) if(!m_pCAP) return;
- if(nID == ID_SHADERS_START)
+ if(nID == ID_SHADERS_OFF)
{
m_shaderlabels.RemoveAll();
}
- else if(nID == ID_SHADERS_START+1)
+ else if(nID == ID_SHADERS_OFFSCR)
+ {
+ m_shaderlabelsScreenSpace.RemoveAll();
+ }
+ else if(nID == ID_SHADERS_COMBINE)
+ {
+ if(IDOK != CShaderCombineDlg(m_shaderlabels, GetModalParent(), false).DoModal())
+ return;
+ }
+ else if(nID == ID_SHADERS_COMBINESCR)
{
- if(IDOK != CShaderCombineDlg(m_shaderlabels, this).DoModal())
+ if(IDOK != CShaderCombineDlg(m_shaderlabelsScreenSpace, GetModalParent(), true).DoModal())
return;
}
- else if(nID >= ID_SHADERS_START+3)
+ else if(nID >= ID_SHADERS_DYNAMIC)
{
MENUITEMINFO mii;
memset(&mii, 0, sizeof(mii));
@@ -6009,17 +6432,28 @@ void CMainFrame::OnUpdatePlayShaders(CCmdUI* pCmdUI) {
if(pCmdUI->m_nID >= ID_SHADERS_START)
{
- pCmdUI->Enable(!!m_pCAP);
+ if (pCmdUI->m_nID >= ID_SHADERS_STARTSCR && pCmdUI->m_nID < ID_SHADERS_ENDSCR )
+ pCmdUI->Enable(!!m_pCAP2);
+ else
+ pCmdUI->Enable(!!m_pCAP);
- if(pCmdUI->m_nID == ID_SHADERS_START)
+ if(pCmdUI->m_nID == ID_SHADERS_OFF)
{
pCmdUI->SetRadio(m_shaderlabels.IsEmpty());
}
- else if(pCmdUI->m_nID == ID_SHADERS_START+1)
+ else if(pCmdUI->m_nID == ID_SHADERS_OFFSCR)
+ {
+ pCmdUI->SetRadio(m_shaderlabelsScreenSpace.IsEmpty());
+ }
+ else if(pCmdUI->m_nID == ID_SHADERS_COMBINE)
{
pCmdUI->SetRadio(m_shaderlabels.GetCount() > 1);
}
- else if(pCmdUI->m_nID == ID_SHADERS_START+2)
+ else if(pCmdUI->m_nID == ID_SHADERS_COMBINESCR)
+ {
+ pCmdUI->SetRadio(m_shaderlabelsScreenSpace.GetCount() > 0);
+ }
+ else if(pCmdUI->m_nID == ID_SHADERS_EDIT)
{
pCmdUI->Enable(TRUE);
}
@@ -6120,13 +6554,13 @@ void CMainFrame::OnPlaySubtitles(UINT nID) STSStyle* val;
pRTS->m_styles.GetNextAssoc(pos, key, val);
- CAutoPtr<CPPageSubStyle> page(new CPPageSubStyle());
+ CAutoPtr<CPPageSubStyle> page(DNew CPPageSubStyle());
page->InitStyle(key, *val);
pages.Add(page);
styles.Add(val);
}
- CPropertySheet dlg(_T("Styles..."), this);
+ CPropertySheet dlg(_T("Styles..."), GetModalParent());
for(int i = 0; i < (int)pages.GetCount(); i++)
dlg.AddPage(pages[i]);
@@ -6888,7 +7322,7 @@ void CMainFrame::OnFavoritesDVD(UINT nID) CComPtr<IDvdState> pDvdState;
HRESULT hr = OleLoadFromStream((IStream*)&stream, IID_IDvdState, (void**)&pDvdState);
- CAutoPtr<OpenDVDData> p(new OpenDVDData());
+ CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
if(p) {p->path = fn; p->pDvdState = pDvdState;}
OpenMedia(p);
}
@@ -7259,8 +7693,15 @@ void CMainFrame::ToggleFullscreen(bool fToNearest, bool fSwitchScreenResWhenHasT m_Change_Monitor = (hm != hm_cur) ? true : false;
if((m_Change_Monitor) && (!m_bToggleShader))
{
- if (m_pCAP) m_pCAP->SetPixelShader(NULL, NULL);
+ if (m_pCAP)
+ m_pCAP->SetPixelShader(NULL, NULL);
+ }
+ if((m_Change_Monitor) && (!m_bToggleShaderScreenSpace))
+ {
+ if (m_pCAP2)
+ m_pCAP2->SetPixelShader2(NULL, NULL, 1);
}
+
}
else
{
@@ -7297,7 +7738,7 @@ void CMainFrame::ToggleFullscreen(bool fToNearest, bool fSwitchScreenResWhenHasT MoveVideoWindow();
- if((m_Change_Monitor) && (!m_bToggleShader)) // Enabled shader ...
+ if((m_Change_Monitor) && (!m_bToggleShader || !m_bToggleShaderScreenSpace)) // Enabled shader ...
{
SetShaders();
}
@@ -7537,7 +7978,8 @@ double CMainFrame::GetZoomAutoFitScale() void CMainFrame::RepaintVideo()
{
- if(m_pCAP) m_pCAP->Paint(false);
+ if(m_pCAP)
+ m_pCAP->Paint(false);
}
void CMainFrame::SetShaders()
@@ -7556,36 +7998,61 @@ void CMainFrame::SetShaders() }
m_pCAP->SetPixelShader(NULL, NULL);
+ if (m_pCAP2)
+ m_pCAP2->SetPixelShader2(NULL, NULL, true);
- CAtlList<CString> labels;
-
- pos = m_shaderlabels.GetHeadPosition();
- while(pos)
+ for (int i = 0; i < 2; ++i)
{
- const AppSettings::Shader* pShader = NULL;
- if(s2s.Lookup(m_shaderlabels.GetNext(pos), pShader))
- {
- CStringA target = pShader->target;
- CStringA srcdata = pShader->srcdata;
+ if (i == 0 && m_bToggleShader)
+ continue;
+ if (i == 1 && m_bToggleShaderScreenSpace)
+ continue;
+ CAtlList<CString> labels;
- HRESULT hr = m_pCAP->SetPixelShader(srcdata, target);
+ CAtlList<CString> *pLabels;
+ if (i == 0)
+ pLabels = &m_shaderlabels;
+ else
+ {
+ if (!m_pCAP2)
+ break;
+ pLabels = &m_shaderlabelsScreenSpace;
+ }
- if(FAILED(hr))
+ pos = pLabels->GetHeadPosition();
+ while(pos)
+ {
+ const AppSettings::Shader* pShader = NULL;
+ if(s2s.Lookup(pLabels->GetNext(pos), pShader))
{
- m_pCAP->SetPixelShader(NULL, NULL);
- SendStatusMessage(ResStr(IDS_MAINFRM_73) + pShader->label, 3000);
- return;
- }
+ CStringA target = pShader->target;
+ CStringA srcdata = pShader->srcdata;
+
+ HRESULT hr;
+ if (i == 0)
+ hr = m_pCAP->SetPixelShader(srcdata, target);
+ else
+ hr = m_pCAP2->SetPixelShader2(srcdata, target, true);
+
+ if(FAILED(hr))
+ {
+ m_pCAP->SetPixelShader(NULL, NULL);
+ if (m_pCAP2)
+ m_pCAP2->SetPixelShader2(NULL, NULL, true);
+ SendStatusMessage(ResStr(IDS_MAINFRM_73) + pShader->label, 3000);
+ return;
+ }
- labels.AddTail(pShader->label);
+ labels.AddTail(pShader->label);
+ }
}
- }
- if(m_iMediaLoadState == MLS_LOADED)
- {
- CString str = Implode(labels, '|');
- str.Replace(_T("|"), _T(", "));
- SendStatusMessage(ResStr(IDS_AG_SHADER) + str, 3000);
+ if(m_iMediaLoadState == MLS_LOADED)
+ {
+ CString str = Implode(labels, '|');
+ str.Replace(_T("|"), _T(", "));
+ SendStatusMessage(ResStr(IDS_AG_SHADER) + str, 3000);
+ }
}
}
@@ -7699,7 +8166,7 @@ void CMainFrame::OpenCreateGraphObject(OpenMediaData* pOMD) AppSettings& s = AfxGetAppSettings();
// CASIMIR666 todo
- if (s.IsD3DFullscreen() && ((s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) || (s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM)) )
+ if (s.IsD3DFullscreen() && ((s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) || (s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM)))
{
CreateFullScreenWindow();
m_pVideoWnd = m_pFullscreenWnd;
@@ -7749,7 +8216,7 @@ void CMainFrame::OpenCreateGraphObject(OpenMediaData* pOMD) //if (!IsRealEngineCompatible(p->fns.GetHead()))
// throw ResStr(IDS_REALVIDEO_INCOMPATIBLE);
- if(!(pUnk = (IUnknown*)(INonDelegatingUnknown*)new CRealMediaGraph(m_pVideoWnd->m_hWnd, hr)))
+ if(!(pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CRealMediaGraph(m_pVideoWnd->m_hWnd, hr)))
throw ResStr(IDS_AG_OUT_OF_MEMORY);
if(SUCCEEDED(hr) && !!(pGB = CComQIPtr<IGraphBuilder>(pUnk)))
@@ -7757,7 +8224,7 @@ void CMainFrame::OpenCreateGraphObject(OpenMediaData* pOMD) }
else if(engine == ShockWave)
{
- if(!(pUnk = (IUnknown*)(INonDelegatingUnknown*)new CShockwaveGraph(m_pVideoWnd->m_hWnd, hr)))
+ if(!(pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CShockwaveGraph(m_pVideoWnd->m_hWnd, hr)))
throw ResStr(IDS_AG_OUT_OF_MEMORY);
if(FAILED(hr) || !(pGB = CComQIPtr<IGraphBuilder>(pUnk)))
@@ -7770,7 +8237,7 @@ void CMainFrame::OpenCreateGraphObject(OpenMediaData* pOMD) #ifdef _WIN64 // TODOX64
MessageBox (ResStr(IDS_MAINFRM_78), _T(""), MB_OK);
#else
- if(!(pUnk = (IUnknown*)(INonDelegatingUnknown*)new CQuicktimeGraph(m_pVideoWnd->m_hWnd, hr)))
+ if(!(pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CQuicktimeGraph(m_pVideoWnd->m_hWnd, hr)))
throw ResStr(IDS_AG_OUT_OF_MEMORY);
if(SUCCEEDED(hr) && !!(pGB = CComQIPtr<IGraphBuilder>(pUnk)))
@@ -7782,16 +8249,16 @@ void CMainFrame::OpenCreateGraphObject(OpenMediaData* pOMD) if(!m_fCustomGraph)
{
- pGB = new CFGManagerPlayer(_T("CFGManagerPlayer"), NULL, m_pVideoWnd->m_hWnd);
+ pGB = DNew CFGManagerPlayer(_T("CFGManagerPlayer"), NULL, m_pVideoWnd->m_hWnd);
}
}
else if(OpenDVDData* p = dynamic_cast<OpenDVDData*>(pOMD))
{
- pGB = new CFGManagerDVD(_T("CFGManagerDVD"), NULL, m_pVideoWnd->m_hWnd);
+ pGB = DNew CFGManagerDVD(_T("CFGManagerDVD"), NULL, m_pVideoWnd->m_hWnd);
}
else if(OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD))
{
- pGB = new CFGManagerCapture(_T("CFGManagerCapture"), NULL, m_pVideoWnd->m_hWnd);
+ pGB = DNew CFGManagerCapture(_T("CFGManagerCapture"), NULL, m_pVideoWnd->m_hWnd);
}
if(!pGB)
@@ -7818,12 +8285,21 @@ void CMainFrame::OpenCreateGraphObject(OpenMediaData* pOMD) throw _T("Could not set target window for graph notification");
}
- m_pProv = (IUnknown*)new CKeyProvider();
+ m_pProv = (IUnknown*)DNew CKeyProvider();
if(CComQIPtr<IObjectWithSite> pObjectWithSite = pGB)
pObjectWithSite->SetSite(m_pProv);
- m_pCB = new CDSMChapterBag(NULL, NULL);
+ m_pCB = DNew CDSMChapterBag(NULL, NULL);
+}
+
+CWnd *CMainFrame::GetModalParent()
+{
+ AppSettings& s = AfxGetAppSettings();
+ CWnd *pParentWnd = this;
+ if (m_pFullscreenWnd->IsWindow() && s.m_RenderSettings.iVMR9FullscreenGUISupport)
+ pParentWnd = m_pFullscreenWnd;
+ return pParentWnd;
}
void CMainFrame::OpenFile(OpenFileData* pOFD)
@@ -7859,7 +8335,7 @@ void CMainFrame::OpenFile(OpenFileData* pOFD) if(s.fReportFailedPins)
{
CComQIPtr<IGraphBuilderDeadEnd> pGBDE = pGB;
- if(pGBDE && pGBDE->GetCount()) CMediaTypesDlg(pGBDE, this).DoModal();
+ if(pGBDE && pGBDE->GetCount()) CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
}
CString err;
@@ -7904,7 +8380,7 @@ void CMainFrame::OpenFile(OpenFileData* pOFD) if(s.fReportFailedPins)
{
CComQIPtr<IGraphBuilderDeadEnd> pGBDE = pGB;
- if(pGBDE && pGBDE->GetCount()) CMediaTypesDlg(pGBDE, this).DoModal();
+ if(pGBDE && pGBDE->GetCount()) CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
}
if(!(pAMOP = pGB))
@@ -8078,7 +8554,7 @@ void CMainFrame::OpenDVD(OpenDVDData* pODD) if(s.fReportFailedPins)
{
CComQIPtr<IGraphBuilderDeadEnd> pGBDE = pGB;
- if(pGBDE && pGBDE->GetCount()) CMediaTypesDlg(pGBDE, this).DoModal();
+ if(pGBDE && pGBDE->GetCount()) CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
}
BeginEnumFilters(pGB, pEF, pBF)
@@ -8299,11 +8775,11 @@ void CMainFrame::OpenCustomizeGraph() {
if(CComQIPtr<IDirectVobSub2> pDVS2 = pBF)
{
-// pDVS2->AdviseSubClock(m_pSubClock = new CSubClock);
+// pDVS2->AdviseSubClock(m_pSubClock = DNew CSubClock);
// break;
// TODO: test multiple dvobsub instances with one clock
- if(!m_pSubClock) m_pSubClock = new CSubClock;
+ if(!m_pSubClock) m_pSubClock = DNew CSubClock;
pDVS2->AdviseSubClock(m_pSubClock);
}
}
@@ -8773,7 +9249,11 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD) else if(OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD.m_p)) OpenCapture(p);
else throw _T("Can't open, invalid input parameters");
+ m_pCAP2 = NULL;
+ m_pCAP = NULL;
+
pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter), (void**)&m_pCAP, TRUE);
+ pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter2), (void**)&m_pCAP2, TRUE);
pGB->FindInterface(__uuidof(IVMRMixerControl9), (void**)&m_pMC, TRUE);
pGB->FindInterface(__uuidof(IVMRMixerBitmap9), (void**)&pVMB, TRUE);
pGB->FindInterface(__uuidof(IMFVideoMixerBitmap), (void**)&pMFVMB, TRUE);
@@ -8944,6 +9424,7 @@ void CMainFrame::CloseMediaPrivate() // if(pVW) pVW->put_MessageDrain((OAHWND)NULL), pVW->put_Owner((OAHWND)NULL);
m_pCAP = NULL; // IMPORTANT: IVMRSurfaceAllocatorNotify/IVMRSurfaceAllocatorNotify9 has to be released before the VMR/VMR9, otherwise it will crash in Release()
+ m_pCAP2 = NULL;
m_pMC = NULL;
m_pMFVDC = NULL;
m_OSD.Stop();
@@ -9195,7 +9676,7 @@ void CMainFrame::SetupFiltersSubMenu() continue;
}
- CAutoPtr<CMenu> pSubSub(new CMenu);
+ CAutoPtr<CMenu> pSubSub(DNew CMenu);
pSubSub->CreatePopupMenu();
int nPPages = 0;
@@ -9970,6 +10451,7 @@ void CMainFrame::SetupFavoritesSubMenu() }
}
+
void CMainFrame::SetupShadersSubMenu()
{
CMenu* pSub = &m_shaders;
@@ -9979,16 +10461,21 @@ void CMainFrame::SetupShadersSubMenu() CWinApp* pApp = AfxGetApp();
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADERS_START, ResStr(IDS_SHADER_OFF));
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADERS_OFF, ResStr(IDS_SHADER_OFF));
- UINT id = ID_SHADERS_START+1;
if(POSITION pos = AfxGetAppSettings().m_shaders.GetHeadPosition())
{
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, ResStr(IDS_SHADER_COMBINE));
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, ResStr(IDS_SHADER_EDIT));
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADERS_COMBINE, ResStr(IDS_SHADER_COMBINE));
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADERS_EDIT, ResStr(IDS_SHADER_EDIT));
pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADER_TOGGLE, ResStr(IDS_SHADER_TOGGLE));
pSub->AppendMenu(MF_SEPARATOR);
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADERS_OFFSCR, ResStr(IDS_SHADER_OFFSCREENSPACE));
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADERS_COMBINESCR, ResStr(IDS_SHADER_COMBINESCREENSPACE));
+ pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADER_TOGGLESCREENSPACE, ResStr(IDS_SHADER_TOGGLESCREENSPACE));
+ pSub->AppendMenu(MF_SEPARATOR);
+
+ UINT id = ID_SHADERS_DYNAMIC;
MENUITEMINFO mii;
memset(&mii, 0, sizeof(mii));
@@ -10085,7 +10572,7 @@ void CMainFrame::AddTextPassThruFilter() || mt.majortype != MEDIATYPE_Text && mt.majortype != MEDIATYPE_Subtitle)
continue;
- CComQIPtr<IBaseFilter> pTPTF = new CTextPassThruFilter(this);
+ CComQIPtr<IBaseFilter> pTPTF = DNew CTextPassThruFilter(this);
CStringW name;
name.Format(L"TextPassThru%08x", pTPTF);
if(FAILED(pGB->AddFilter(pTPTF, name)))
@@ -10116,14 +10603,14 @@ bool CMainFrame::LoadSubtitle(CString fn) {
if(!pSubStream)
{
- CAutoPtr<CVobSubFile> pVSF(new CVobSubFile(&m_csSubLock));
+ CAutoPtr<CVobSubFile> pVSF(DNew CVobSubFile(&m_csSubLock));
if(CString(CPath(fn).GetExtension()).MakeLower() == _T(".idx") && pVSF && pVSF->Open(fn) && pVSF->GetStreamCount() > 0)
pSubStream = pVSF.Detach();
}
if(!pSubStream)
{
- CAutoPtr<CRenderedTextSubtitle> pRTS(new CRenderedTextSubtitle(&m_csSubLock));
+ CAutoPtr<CRenderedTextSubtitle> pRTS(DNew CRenderedTextSubtitle(&m_csSubLock));
if(pRTS && pRTS->Open(fn, DEFAULT_CHARSET) && pRTS->GetStreamCount() > 0)
pSubStream = pRTS.Detach();
}
@@ -10668,8 +11155,10 @@ bool CMainFrame::BuildGraphVideoAudio(int fVPreview, bool fVCapture, int fAPrevi if(fVidPrev)
{
m_pCAP = NULL;
+ m_pCAP2 = NULL;
pGB->Render(pVidPrevPin);
pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter), (void**)&m_pCAP, TRUE);
+ pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter2), (void**)&m_pCAP2, TRUE);
}
if(fVidCap)
@@ -10811,10 +11300,12 @@ void CMainFrame::ShowOptions(int idPage) {
AppSettings& s = AfxGetAppSettings();
- CPPageSheet options(ResStr(IDS_OPTIONS_CAPTION), pGB, this, idPage);
+ CPPageSheet options(ResStr(IDS_OPTIONS_CAPTION), pGB, GetModalParent(), idPage);
+ m_bInOptions = true;
if(options.DoModal() == IDOK)
{
+ m_bInOptions = false;
if(!m_fFullScreen)
SetAlwaysOnTop(s.iOnTop);
@@ -10822,12 +11313,13 @@ void CMainFrame::ShowOptions(int idPage) s.UpdateData(true);
}
+ m_bInOptions = false;
}
void CMainFrame::StartWebServer(int nPort)
{
if(!m_pWebServer)
- m_pWebServer.Attach(new CWebServer(this, nPort));
+ m_pWebServer.Attach(DNew CWebServer(this, nPort));
}
void CMainFrame::StopWebServer()
diff --git a/src/apps/mplayerc/MainFrm.h b/src/apps/mplayerc/MainFrm.h index 6fb7eb658..ad0b09799 100644 --- a/src/apps/mplayerc/MainFrm.h +++ b/src/apps/mplayerc/MainFrm.h @@ -197,6 +197,7 @@ class CMainFrame : public CFrameWnd, public CDropTarget CComPtr<IAMDroppedFrames> pAMDF;
CComPtr<ISubPicAllocatorPresenter> m_pCAP;
+ CComPtr<ISubPicAllocatorPresenter2> m_pCAP2;
void SetBalance(int balance);
@@ -360,6 +361,8 @@ protected: void SendNowPlayingToMSN();
void SendNowPlayingTomIRC();
+ CWnd *GetModalParent();
+
void OpenCreateGraphObject(OpenMediaData* pOMD);
void OpenFile(OpenFileData* pOFD);
void OpenDVD(OpenDVDData* pODD);
@@ -413,6 +416,7 @@ public: // shaders
CAtlList<CString> m_shaderlabels;
+ CAtlList<CString> m_shaderlabelsScreenSpace;
void SetShaders();
void UpdateShaders(CString label);
@@ -640,8 +644,46 @@ public: afx_msg void OnViewTearingTest();
afx_msg void OnUpdateViewDisplayStats(CCmdUI* pCmdUI);
afx_msg void OnViewDisplayStats();
+ afx_msg void OnViewDisplayStatsSC();
+ afx_msg void OnUpdateViewVSync(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewVSyncOffset(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewVSyncAccurate(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewFlushGPU(CCmdUI* pCmdUI);
+
+ afx_msg void OnUpdateViewD3DFullscreen(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewDisableDesktopComposition(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewAlternativeVSync(CCmdUI* pCmdUI);
+
+ afx_msg void OnUpdateViewEVROutputRange(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewFullscreenGUISupport(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewHighColorResolution(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewEnableFrameTimeCorrection(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewVSyncOffsetIncrease(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewVSyncOffsetDecrease(CCmdUI* pCmdUI);
+ afx_msg void OnViewVSync();
+ afx_msg void OnViewVSyncAccurate();
+ afx_msg void OnViewEVROutputRange_0_255();
+ afx_msg void OnViewEVROutputRange_16_235();
+
+ afx_msg void OnViewFlushGPUBeforeVSync();
+ afx_msg void OnViewFlushGPUAfterVSync();
+ afx_msg void OnViewFlushGPUWait();
+
+ afx_msg void OnViewD3DFullScreen();
+ afx_msg void OnViewDisableDesktopComposition();
+ afx_msg void OnViewAlternativeVSync();
+ afx_msg void OnViewResetDefault();
+ afx_msg void OnViewResetOptimal();
+
+ afx_msg void OnViewFullscreenGUISupport();
+ afx_msg void OnViewHighColorResolution();
+ afx_msg void OnViewEnableFrameTimeCorrection();
+ afx_msg void OnViewVSyncOffsetIncrease();
+ afx_msg void OnViewVSyncOffsetDecrease();
afx_msg void OnUpdateShaderToggle(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateShaderToggleScreenSpace(CCmdUI* pCmdUI);
afx_msg void OnShaderToggle();
+ afx_msg void OnShaderToggleScreenSpace();
afx_msg void OnUpdateViewRemainingTime(CCmdUI* pCmdUI);
afx_msg void OnViewRemainingTime();
afx_msg void OnD3DFullscreenToggle();
@@ -739,6 +781,8 @@ public: __int64 m_rtCurSubPos;
CString m_strTitle;
bool m_bToggleShader;
+ bool m_bToggleShaderScreenSpace;
+ bool m_bInOptions;
void SetLoadState(MPC_LOADSTATE iState);
void SetPlayState(MPC_PLAYSTATE iState);
diff --git a/src/apps/mplayerc/MediaFormats.cpp b/src/apps/mplayerc/MediaFormats.cpp index 25232ecc5..0be5b62f1 100644 --- a/src/apps/mplayerc/MediaFormats.cpp +++ b/src/apps/mplayerc/MediaFormats.cpp @@ -220,7 +220,7 @@ void CMediaFormats::UpdateData(bool fSave) ADDFMT((ResStr(IDS_MEDIAFORMATS_28), _T("flv")));
ADDFMT((ResStr(IDS_MEDIAFORMATS_29), _T("swf"), false, _T("ShockWave ActiveX control"), ShockWave));
ADDFMT((ResStr(IDS_MEDIAFORMATS_30), _T("mov 3g2 3gp2"), false, _T("QuickTime (Alternative)"), QuickTime));
- ADDFMT((ResStr(IDS_AG_PLAYLIST_FILE), _T("asx m3u pls wvx wax wmx mpcpl")));
+ ADDFMT((ResStr(IDS_AG_PLAYLIST_FILE), _T("asx m3u pls wvx wax wmx mpcpl bdmv")));
ADDFMT((ResStr(IDS_AG_OTHER), _T("divx vp6 rmvb amv tta amr")));
#undef ADDFMT
diff --git a/src/apps/mplayerc/Monitors.cpp b/src/apps/mplayerc/Monitors.cpp index c32310bdc..637a0285e 100644 --- a/src/apps/mplayerc/Monitors.cpp +++ b/src/apps/mplayerc/Monitors.cpp @@ -54,7 +54,7 @@ BOOL CALLBACK CMonitors::AddMonitorsCallBack( HMONITOR hMonitor, HDC hdcMonitor, {
LPADDMONITOR pAddMonitor = (LPADDMONITOR)dwData;
- CMonitor* pMonitor = new CMonitor;
+ CMonitor* pMonitor = DNew CMonitor;
pMonitor->Attach( hMonitor );
pAddMonitor->pMonitors->Add( pMonitor );
diff --git a/src/apps/mplayerc/OpenFileDlg.cpp b/src/apps/mplayerc/OpenFileDlg.cpp index fa9fd13e2..69ac969d0 100644 --- a/src/apps/mplayerc/OpenFileDlg.cpp +++ b/src/apps/mplayerc/OpenFileDlg.cpp @@ -43,7 +43,7 @@ COpenFileDlg::COpenFileDlg(CAtlArray<CString>& mask, bool fAllowDirSelection, LP m_fAllowDirSelection = fAllowDirSelection;
m_pOFN->lpstrInitialDir = lpszFileName;
- m_buff = new TCHAR[10000];
+ m_buff = DNew TCHAR[10000];
m_buff[0] = 0;
m_pOFN->lpstrFile = m_buff;
m_pOFN->nMaxFile = 10000;
diff --git a/src/apps/mplayerc/PPageExternalFilters.cpp b/src/apps/mplayerc/PPageExternalFilters.cpp index d84525e45..7a1c04107 100644 --- a/src/apps/mplayerc/PPageExternalFilters.cpp +++ b/src/apps/mplayerc/PPageExternalFilters.cpp @@ -289,7 +289,7 @@ BOOL CPPageExternalFilters::OnInitDialog() POSITION pos = s.filters.GetHeadPosition();
while(pos)
{
- CAutoPtr<FilterOverride> f(new FilterOverride(s.filters.GetNext(pos)));
+ CAutoPtr<FilterOverride> f(DNew FilterOverride(s.filters.GetNext(pos)));
CString name(_T("<unknown>"));
@@ -328,7 +328,7 @@ BOOL CPPageExternalFilters::OnApply() {
if(POSITION pos = (POSITION)m_filters.GetItemData(i))
{
- CAutoPtr<FilterOverride> f(new FilterOverride(m_pFilters.GetAt(pos)));
+ CAutoPtr<FilterOverride> f(DNew FilterOverride(m_pFilters.GetAt(pos)));
f->fDisabled = !m_filters.GetCheck(i);
s.filters.AddTail(f);
}
diff --git a/src/apps/mplayerc/PPageFileInfoSheet.cpp b/src/apps/mplayerc/PPageFileInfoSheet.cpp index 6b18b5a52..bbd3d62a0 100644 --- a/src/apps/mplayerc/PPageFileInfoSheet.cpp +++ b/src/apps/mplayerc/PPageFileInfoSheet.cpp @@ -30,16 +30,16 @@ // CPPageFileInfoSheet
IMPLEMENT_DYNAMIC(CPPageFileInfoSheet, CPropertySheet)
-CPPageFileInfoSheet::CPPageFileInfoSheet(CString fn, CMainFrame* pParentWnd)
+CPPageFileInfoSheet::CPPageFileInfoSheet(CString fn, CMainFrame* pMainFrame, CWnd* pParentWnd)
: CPropertySheet(ResStr(IDS_PROPSHEET_PROPERTIES), pParentWnd, 0)
- , m_clip(fn, pParentWnd->pGB)
- , m_details(fn, pParentWnd->pGB, pParentWnd->m_pCAP)
- , m_res(fn, pParentWnd->pGB)
+ , m_clip(fn, pMainFrame->pGB)
+ , m_details(fn, pMainFrame->pGB, pMainFrame->m_pCAP)
+ , m_res(fn, pMainFrame->pGB)
{
AddPage(&m_clip);
AddPage(&m_details);
- BeginEnumFilters(pParentWnd->pGB, pEF, pBF)
+ BeginEnumFilters(pMainFrame->pGB, pEF, pBF)
{
if(CComQIPtr<IDSMResourceBag> pRB = pBF)
if(pRB && pRB->ResGetCount() > 0)
diff --git a/src/apps/mplayerc/PPageFileInfoSheet.h b/src/apps/mplayerc/PPageFileInfoSheet.h index 7755e097c..1fe2fa58f 100644 --- a/src/apps/mplayerc/PPageFileInfoSheet.h +++ b/src/apps/mplayerc/PPageFileInfoSheet.h @@ -42,7 +42,7 @@ private: CPPageFileInfoRes m_res;
public:
- CPPageFileInfoSheet(CString fn, CMainFrame* pParentWnd);
+ CPPageFileInfoSheet(CString fn, CMainFrame* pMainFrame, CWnd* pParentWnd);
virtual ~CPPageFileInfoSheet();
protected:
diff --git a/src/apps/mplayerc/PPageOutput.cpp b/src/apps/mplayerc/PPageOutput.cpp index f6ef30d88..a7153a54f 100644 --- a/src/apps/mplayerc/PPageOutput.cpp +++ b/src/apps/mplayerc/PPageOutput.cpp @@ -40,11 +40,12 @@ CPPageOutput::CPPageOutput() , m_iQTVideoRendererType(0)
, m_iAPSurfaceUsage(0)
, m_iAudioRendererType(0)
- , m_fVMRSyncFix(FALSE)
+// , m_fVMRSyncFix(FALSE)
, m_iDX9Resizer(0)
, m_fVMR9MixerMode(FALSE)
, m_fVMR9MixerYUV(FALSE)
- , m_iEvrBuffers(5)
+ , m_fVMR9AlterativeVSync(FALSE)
+ , m_iEvrBuffers(L"5")
{
}
@@ -62,12 +63,14 @@ void CPPageOutput::DoDataExchange(CDataExchange* pDX) DDX_CBIndex(pDX, IDC_DX_SURFACE, m_iAPSurfaceUsage);
DDX_CBIndex(pDX, IDC_COMBO1, m_iAudioRendererType);
DDX_Control(pDX, IDC_COMBO1, m_iAudioRendererTypeCtrl);
- DDX_Check(pDX, IDC_CHECK1, m_fVMRSyncFix);
+// DDX_Check(pDX, IDC_CHECK1, m_fVMRSyncFix);
DDX_CBIndex(pDX, IDC_DX9RESIZER_COMBO, m_iDX9Resizer);
DDX_Check(pDX, IDC_DSVMR9LOADMIXER, m_fVMR9MixerMode);
DDX_Check(pDX, IDC_DSVMR9YUVMIXER, m_fVMR9MixerYUV);
+ DDX_Check(pDX, IDC_DSVMR9ALTERNATIVEVSYNC, m_fVMR9AlterativeVSync);
DDX_Check(pDX, IDC_FULLSCREEN_MONITOR_CHECK, m_fD3DFullscreen);
- DDX_CBIndex(pDX, IDC_EVR_BUFFERS, m_iEvrBuffers);
+
+ DDX_CBString(pDX, IDC_EVR_BUFFERS, m_iEvrBuffers);
DDX_CBIndex(pDX, IDC_COMBO2, m_iMonitorType);
DDX_Control(pDX, IDC_COMBO2, m_iMonitorTypeCtrl);
@@ -76,7 +79,7 @@ void CPPageOutput::DoDataExchange(CDataExchange* pDX) BEGIN_MESSAGE_MAP(CPPageOutput, CPPageBase)
ON_UPDATE_COMMAND_UI(IDC_DSVMR9YUVMIXER, OnUpdateMixerYUV)
ON_CBN_SELCHANGE(IDC_DX_SURFACE, &CPPageOutput::OnSurfaceChange)
- ON_CONTROL_RANGE(BN_CLICKED, IDC_DSSYSDEF, IDC_EVR_CUSTOM, &CPPageOutput::OnDSRendererChange)
+ ON_CONTROL_RANGE(BN_CLICKED, IDC_DSSYSDEF, IDC_DSMADVR, &CPPageOutput::OnDSRendererChange)
ON_BN_CLICKED(IDC_FULLSCREEN_MONITOR_CHECK, OnFullscreenCheck)
END_MESSAGE_MAP()
@@ -103,12 +106,13 @@ BOOL CPPageOutput::OnInitDialog() m_iRMVideoRendererType = s.iRMVideoRendererType;
m_iQTVideoRendererType = s.iQTVideoRendererType;
m_iAPSurfaceUsage = s.iAPSurfaceUsage;
- m_fVMRSyncFix = s.fVMRSyncFix;
+// m_fVMRSyncFix = s.fVMRSyncFix;
m_iDX9Resizer = s.iDX9Resizer;
m_fVMR9MixerMode = s.fVMR9MixerMode;
m_fVMR9MixerYUV = s.fVMR9MixerYUV;
+ m_fVMR9AlterativeVSync = s.m_RenderSettings.fVMR9AlterativeVSync;
m_fD3DFullscreen = s.fD3DFullscreen;
- m_iEvrBuffers = s.iEvrBuffers-3;
+ m_iEvrBuffers.Format(L"%d", s.iEvrBuffers);
// Multi-Monitor code
CString str;
@@ -244,6 +248,11 @@ BOOL CPPageOutput::OnInitDialog() DisableRadioButton(IDC_DSDXR, IDC_DSSYSDEF);
}
+ if(!IsCLSIDRegistered(CLSID_madVR))
+ {
+ DisableRadioButton(IDC_DSMADVR, IDC_DSSYSDEF);
+ }
+
// YUV mixing is not compatible with Vista
if (AfxGetMyApp()->IsVistaOrAbove())
{
@@ -268,13 +277,22 @@ BOOL CPPageOutput::OnApply() s.iRMVideoRendererType = m_iRMVideoRendererType;
s.iQTVideoRendererType = m_iQTVideoRendererType;
s.iAPSurfaceUsage = m_iAPSurfaceUsage;
- s.fVMRSyncFix = !!m_fVMRSyncFix;
+// s.fVMRSyncFix = !!m_fVMRSyncFix;
s.AudioRendererDisplayName = m_AudioRendererDisplayNames[m_iAudioRendererType];
s.iDX9Resizer = m_iDX9Resizer;
s.fVMR9MixerMode = !!m_fVMR9MixerMode;
s.fVMR9MixerYUV = !!m_fVMR9MixerYUV;
+ s.m_RenderSettings.fVMR9AlterativeVSync = m_fVMR9AlterativeVSync != 0;
s.fD3DFullscreen = m_fD3DFullscreen ? true : false;
- s.iEvrBuffers = m_iEvrBuffers+3;
+
+ if (!m_iEvrBuffers.IsEmpty())
+ {
+ int Temp = 5;
+ swscanf(m_iEvrBuffers.GetBuffer(), L"%d", &Temp);
+ s.iEvrBuffers = Temp;
+ }
+ else
+ s.iEvrBuffers = 5;
s.f_hmonitor = m_MonitorDisplayNames[m_iMonitorType];
@@ -297,7 +315,8 @@ void CPPageOutput::OnDSRendererChange(UINT nIDbutton) GetDlgItem(IDC_FULLSCREEN_MONITOR_CHECK)->EnableWindow(FALSE);
GetDlgItem(IDC_DSVMR9LOADMIXER)->EnableWindow(FALSE);
GetDlgItem(IDC_DSVMR9YUVMIXER)->EnableWindow(FALSE);
- GetDlgItem(IDC_CHECK1)->EnableWindow(FALSE);
+ GetDlgItem(IDC_DSVMR9ALTERNATIVEVSYNC)->EnableWindow(FALSE);
+// GetDlgItem(IDC_CHECK1)->EnableWindow(FALSE);
GetDlgItem(IDC_EVR_BUFFERS)->EnableWindow((nIDbutton - IDC_DSSYSDEF) == 11);
GetDlgItem(IDC_EVR_BUFFERS_TXT)->EnableWindow((nIDbutton - IDC_DSSYSDEF) == 11);
@@ -306,10 +325,12 @@ void CPPageOutput::OnDSRendererChange(UINT nIDbutton) case 6 : // VMR9 renderless
GetDlgItem(IDC_DSVMR9LOADMIXER)->EnableWindow(TRUE);
GetDlgItem(IDC_DSVMR9YUVMIXER)->EnableWindow(TRUE);
+ GetDlgItem(IDC_DSVMR9ALTERNATIVEVSYNC)->EnableWindow(TRUE);
case 11 : // EVR custom presenter
GetDlgItem(IDC_DX9RESIZER_COMBO)->EnableWindow(TRUE);
GetDlgItem(IDC_FULLSCREEN_MONITOR_CHECK)->EnableWindow(TRUE);
- GetDlgItem(IDC_CHECK1)->EnableWindow(TRUE); // Lock back buffer
+// GetDlgItem(IDC_CHECK1)->EnableWindow(TRUE); // Lock back buffer
+ GetDlgItem(IDC_DSVMR9ALTERNATIVEVSYNC)->EnableWindow(TRUE);
// Force 3D surface with EVR Custom
if (nIDbutton - IDC_DSSYSDEF == 11)
diff --git a/src/apps/mplayerc/PPageOutput.h b/src/apps/mplayerc/PPageOutput.h index 0ddccd8d4..440243fd4 100644 --- a/src/apps/mplayerc/PPageOutput.h +++ b/src/apps/mplayerc/PPageOutput.h @@ -51,12 +51,13 @@ public: int m_iAPSurfaceUsage;
int m_iAudioRendererType;
CComboBox m_iAudioRendererTypeCtrl;
- BOOL m_fVMRSyncFix;
+// BOOL m_fVMRSyncFix;
int m_iDX9Resizer;
BOOL m_fVMR9MixerMode;
BOOL m_fVMR9MixerYUV;
BOOL m_fD3DFullscreen;
- int m_iEvrBuffers;
+ BOOL m_fVMR9AlterativeVSync;
+ CString m_iEvrBuffers;
int m_iMonitorType;
CComboBox m_iMonitorTypeCtrl;
diff --git a/src/apps/mplayerc/PPageSheet.cpp b/src/apps/mplayerc/PPageSheet.cpp index 18f5252ba..f6847c05e 100644 --- a/src/apps/mplayerc/PPageSheet.cpp +++ b/src/apps/mplayerc/PPageSheet.cpp @@ -76,7 +76,7 @@ CPPageSheet::~CPPageSheet() CTreeCtrl* CPPageSheet::CreatePageTreeObject()
{
- return new CTreePropSheetTreeCtrl();
+ return DNew CTreePropSheetTreeCtrl();
}
BEGIN_MESSAGE_MAP(CPPageSheet, CTreePropSheet)
diff --git a/src/apps/mplayerc/PPageSubtitles.cpp b/src/apps/mplayerc/PPageSubtitles.cpp index 3783bf12c..383d73103 100644 --- a/src/apps/mplayerc/PPageSubtitles.cpp +++ b/src/apps/mplayerc/PPageSubtitles.cpp @@ -37,6 +37,7 @@ CPPageSubtitles::CPPageSubtitles() , m_nVerPos(0)
, m_nSPCSize(0)
, m_fSPCPow2Tex(FALSE)
+ , m_fSPCDisableAnim(FALSE)
, m_nSubDelayInterval(0)
{
}
@@ -59,6 +60,7 @@ void CPPageSubtitles::DoDataExchange(CDataExchange* pDX) DDX_Control(pDX, IDC_EDIT2, m_nHorPosEdit);
DDX_Control(pDX, IDC_EDIT3, m_nVerPosEdit);
DDX_Check(pDX, IDC_CHECK_SPCPOW2TEX, m_fSPCPow2Tex);
+ DDX_Check(pDX, IDC_CHECK_SPCDISABLEANIM, m_fSPCDisableAnim);
DDX_Text(pDX, IDC_EDIT4, m_nSubDelayInterval);
}
@@ -78,6 +80,48 @@ END_MESSAGE_MAP() // CPPageSubtitles message handlers
+int TranslateResIn(int _In)
+{
+ switch (_In)
+ {
+ case 0:
+ return 0;
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ return _In + 4;
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ return _In - 5;
+ }
+ return _In;
+}
+
+int TranslateResOut(int _In)
+{
+ switch (_In)
+ {
+ case 0:
+ return 0;
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ return _In + 5;
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ return _In - 4;
+ }
+ return _In;
+}
+
BOOL CPPageSubtitles::OnInitDialog()
{
__super::OnInitDialog();
@@ -90,15 +134,20 @@ BOOL CPPageSubtitles::OnInitDialog() m_nVerPos = s.nVerPos;
m_nVerPosCtrl.SetRange(110,-10);
m_nSPCSize = s.nSPCSize;
- m_nSPCSizeCtrl.SetRange(0, 10);
+ m_nSPCSizeCtrl.SetRange(0, 60);
m_spmaxres.AddString(_T("Desktop"));
+ m_spmaxres.AddString(_T("2560x1600"));
+ m_spmaxres.AddString(_T("1920x1080"));
+ m_spmaxres.AddString(_T("1320x900"));
+ m_spmaxres.AddString(_T("1280x720"));
m_spmaxres.AddString(_T("1024x768"));
m_spmaxres.AddString(_T("800x600"));
m_spmaxres.AddString(_T("640x480"));
m_spmaxres.AddString(_T("512x384"));
m_spmaxres.AddString(_T("384x288"));
- m_spmaxres.SetCurSel(s.nSPCMaxRes);
+ m_spmaxres.SetCurSel(TranslateResIn(s.nSPCMaxRes));
m_fSPCPow2Tex = s.fSPCPow2Tex;
+ m_fSPCDisableAnim = s.fSPCDisableAnim;
m_nSubDelayInterval = s.nSubDelayInterval;
UpdateData(FALSE);
@@ -120,16 +169,18 @@ BOOL CPPageSubtitles::OnApply() || s.nVerPos != m_nVerPos
|| s.nSPCSize != m_nSPCSize
|| s.nSubDelayInterval != m_nSubDelayInterval
- || s.nSPCMaxRes != m_spmaxres.GetCurSel()
- || s.fSPCPow2Tex != !!m_fSPCPow2Tex)
+ || s.nSPCMaxRes != TranslateResOut(m_spmaxres.GetCurSel())
+ || s.fSPCPow2Tex != !!m_fSPCPow2Tex
+ || s.fSPCDisableAnim != !!m_fSPCDisableAnim)
{
s.fOverridePlacement = !!m_fOverridePlacement;
s.nHorPos = m_nHorPos;
s.nVerPos = m_nVerPos;
s.nSPCSize = m_nSPCSize;
s.nSubDelayInterval = m_nSubDelayInterval;
- s.nSPCMaxRes = m_spmaxres.GetCurSel();
+ s.nSPCMaxRes = TranslateResOut(m_spmaxres.GetCurSel());
s.fSPCPow2Tex = !!m_fSPCPow2Tex;
+ s.fSPCDisableAnim = !!m_fSPCDisableAnim;
if(CMainFrame* pFrame = (CMainFrame*)GetParentFrame())
pFrame->UpdateSubtitle(true);
diff --git a/src/apps/mplayerc/PPageSubtitles.h b/src/apps/mplayerc/PPageSubtitles.h index 1e37b280d..cdad23e66 100644 --- a/src/apps/mplayerc/PPageSubtitles.h +++ b/src/apps/mplayerc/PPageSubtitles.h @@ -47,6 +47,7 @@ public: CSpinButtonCtrl m_nSPCSizeCtrl;
CComboBox m_spmaxres;
BOOL m_fSPCPow2Tex;
+ BOOL m_fSPCDisableAnim;
int m_nSubDelayInterval;
// Dialog Data
diff --git a/src/apps/mplayerc/PlayerCaptureDialog.cpp b/src/apps/mplayerc/PlayerCaptureDialog.cpp index 3d59072fc..8246c37c8 100644 --- a/src/apps/mplayerc/PlayerCaptureDialog.cpp +++ b/src/apps/mplayerc/PlayerCaptureDialog.cpp @@ -260,7 +260,7 @@ static void SetupMediaTypes(CComPtr<IAMStreamConfig> pAMSC, CFormatArray<T>& tfa {
int extra = mt.cbFormat - sizeof(VIDEOINFOHEADER);
int bmiHeaderSize = sizeof(vih->bmiHeader) + extra;
- BYTE* pbmiHeader = new BYTE[bmiHeaderSize];
+ BYTE* pbmiHeader = DNew BYTE[bmiHeaderSize];
memcpy(pbmiHeader, &vih->bmiHeader, bmiHeaderSize);
mt.ReallocFormatBuffer(FIELD_OFFSET(VIDEOINFOHEADER2, bmiHeader) + bmiHeaderSize);
VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
@@ -827,11 +827,11 @@ void CPlayerCaptureDialog::UpdateMuxer() if(m_muxtype == 0) m_pMux.CoCreateInstance(CLSID_AviDest);
else if(m_muxtype == 1) m_pMux.CoCreateInstance(CLSID_OggMux);
- else if(m_muxtype == 2) m_pMux = new CMatroskaMuxerFilter(NULL, &hr);
- else if(m_muxtype == 3) m_pMux = new CDSMMuxerFilter(NULL, &hr);
+ else if(m_muxtype == 2) m_pMux = DNew CMatroskaMuxerFilter(NULL, &hr);
+ else if(m_muxtype == 3) m_pMux = DNew CDSMMuxerFilter(NULL, &hr);
else return;
- if(m_fSepAudio) m_pAudMux = new CWavDestFilter(NULL, &hr);
+ if(m_fSepAudio) m_pAudMux = DNew CWavDestFilter(NULL, &hr);
}
void CPlayerCaptureDialog::UpdateOutputControls()
@@ -1558,11 +1558,11 @@ void CPlayerCaptureDialog::OnRecord() }
}
- m_pVidBuffer = m_fVidOutput && m_nVidBuffers > 0 && m_muxtype != 2 && m_muxtype != 3 ? new CBufferFilter(NULL, NULL) : NULL;
+ m_pVidBuffer = m_fVidOutput && m_nVidBuffers > 0 && m_muxtype != 2 && m_muxtype != 3 ? DNew CBufferFilter(NULL, NULL) : NULL;
if(CComQIPtr<IBufferFilter> pVB = m_pVidBuffer)
{pVB->SetBuffers(m_nVidBuffers); pVB->SetPriority(THREAD_PRIORITY_NORMAL);}
- m_pAudBuffer = m_fAudOutput && m_nAudBuffers > 0 && m_muxtype != 2 && m_muxtype != 3 ? new CBufferFilter(NULL, NULL) : NULL;
+ m_pAudBuffer = m_fAudOutput && m_nAudBuffers > 0 && m_muxtype != 2 && m_muxtype != 3 ? DNew CBufferFilter(NULL, NULL) : NULL;
if(CComQIPtr<IBufferFilter> pAB = m_pAudBuffer)
{pAB->SetBuffers(m_nAudBuffers); pAB->SetPriority(THREAD_PRIORITY_ABOVE_NORMAL);}
diff --git a/src/apps/mplayerc/PlayerCaptureDialog.h b/src/apps/mplayerc/PlayerCaptureDialog.h index 01616568b..7f68741cd 100644 --- a/src/apps/mplayerc/PlayerCaptureDialog.h +++ b/src/apps/mplayerc/PlayerCaptureDialog.h @@ -64,7 +64,7 @@ public: if(fCreate)
{
- CAutoPtr<CFormat<T> > pf(new CFormat<T>(name));
+ CAutoPtr<CFormat<T> > pf(DNew CFormat<T>(name));
CFormat<T>* tmp = pf;
Add(pf);
return(tmp);
@@ -126,7 +126,7 @@ public: CFormat<T>* pf = Find(MakeFormatName(pmt), true);
if(!pf) {DeleteMediaType(pmt); return(false);}
- CAutoPtr<CFormatElem<T> > pfe(new CFormatElem<T>());
+ CAutoPtr<CFormatElem<T> > pfe(DNew CFormatElem<T>());
pfe->mt = *pmt;
pfe->caps = caps;
pf->Add(pfe);
diff --git a/src/apps/mplayerc/PlayerInfoBar.cpp b/src/apps/mplayerc/PlayerInfoBar.cpp index b7d67a0af..740649a74 100644 --- a/src/apps/mplayerc/PlayerInfoBar.cpp +++ b/src/apps/mplayerc/PlayerInfoBar.cpp @@ -58,11 +58,11 @@ void CPlayerInfoBar::SetLine(CString label, CString info) }
}
- CAutoPtr<CStatusLabel> l(new CStatusLabel(true, false));
+ CAutoPtr<CStatusLabel> l(DNew CStatusLabel(true, false));
l->Create(label, WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|SS_OWNERDRAW, CRect(0,0,0,0), this);
m_label.Add(l);
- CAutoPtr<CStatusLabel> i(new CStatusLabel(false, true));
+ CAutoPtr<CStatusLabel> i(DNew CStatusLabel(false, true));
i->Create(info, WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|SS_OWNERDRAW, CRect(0,0,0,0), this);
m_info.Add(i);
diff --git a/src/apps/mplayerc/PlayerListCtrl.cpp b/src/apps/mplayerc/PlayerListCtrl.cpp index 7862412dd..8aa676018 100644 --- a/src/apps/mplayerc/PlayerListCtrl.cpp +++ b/src/apps/mplayerc/PlayerListCtrl.cpp @@ -491,7 +491,7 @@ CImageList* CPlayerListCtrl::CreateDragImageEx(LPPOINT lpPoint) //
// Create the imagelist with the merged drag images
//
- CImageList* pCompleteImageList = new CImageList;
+ CImageList* pCompleteImageList = DNew CImageList;
pCompleteImageList->Create(cCompleteRect.Width(),
cCompleteRect.Height(),
@@ -566,7 +566,7 @@ CEdit* CPlayerListCtrl::ShowInPlaceEdit(int nItem, int nCol) : (lvcol.fmt&LVCFMT_JUSTIFYMASK) == LVCFMT_RIGHT ? ES_RIGHT
: ES_CENTER;
- CEdit* pEdit = new CInPlaceEdit(nItem, nCol, GetItemText(nItem, nCol));
+ CEdit* pEdit = DNew CInPlaceEdit(nItem, nCol, GetItemText(nItem, nCol));
pEdit->Create(dwStyle, rect, this, IDC_EDIT1);
m_fInPlaceDirty = false;
@@ -582,7 +582,7 @@ CComboBox* CPlayerListCtrl::ShowInPlaceComboBox(int nItem, int nCol, CAtlList<CS DWORD dwStyle = /*WS_BORDER|*/WS_CHILD|WS_VISIBLE|WS_VSCROLL/*|WS_HSCROLL*/
|CBS_DROPDOWNLIST|CBS_DISABLENOSCROLL/*|CBS_NOINTEGRALHEIGHT*/;
- CComboBox* pComboBox = new CInPlaceComboBox(nItem, nCol, lstItems, nSel);
+ CComboBox* pComboBox = DNew CInPlaceComboBox(nItem, nCol, lstItems, nSel);
pComboBox->Create(dwStyle, rect, this, IDC_COMBO1);
CorrectComboListWidth(*pComboBox, GetFont());
@@ -603,7 +603,7 @@ CListBox* CPlayerListCtrl::ShowInPlaceListBox(int nItem, int nCol, CAtlList<CStr return(NULL);
DWORD dwStyle = WS_BORDER|WS_CHILD|WS_VISIBLE|WS_VSCROLL/*|WS_HSCROLL*/|LBS_NOTIFY;
- CListBox* pListBox = new CInPlaceListBox(nItem, nCol, lstItems, nSel);
+ CListBox* pListBox = DNew CInPlaceListBox(nItem, nCol, lstItems, nSel);
pListBox->Create(dwStyle, rect, this, IDC_LIST1);
CRect ir;
diff --git a/src/apps/mplayerc/PlayerPlaylistBar.cpp b/src/apps/mplayerc/PlayerPlaylistBar.cpp index 8658cea53..35cea3dce 100644 --- a/src/apps/mplayerc/PlayerPlaylistBar.cpp +++ b/src/apps/mplayerc/PlayerPlaylistBar.cpp @@ -316,6 +316,11 @@ void CPlayerPlaylistBar::ParsePlayList(CAtlList<CString>& fns, CAtlList<CString> ParseMPCPlayList(fns.GetHead());
return;
}
+ else if(ct == "application/x-bdmv-playlist")
+ {
+ ParseBDMVPlayList(fns.GetHead());
+ return;
+ }
AddItem(fns, subs);
}
@@ -332,6 +337,22 @@ static CString CombinePath(CPath p, CString fn) return (LPCTSTR)p;
}
+bool CPlayerPlaylistBar::ParseBDMVPlayList(CString fn)
+{
+ CHdmvClipInfo ClipInfo;
+ CAtlList<CString> MainPlaylist;
+
+ CPath Path(fn);
+ Path.RemoveFileSpec();
+
+ if (SUCCEEDED (ClipInfo.FindMainMovie (Path + L"\\", MainPlaylist)))
+ {
+ Append(MainPlaylist, MainPlaylist.GetCount()>1, NULL);
+ }
+
+ return m_pl.GetCount() > 0;
+}
+
bool CPlayerPlaylistBar::ParseMPCPlayList(CString fn)
{
CString str;
@@ -653,7 +674,7 @@ OpenMediaData* CPlayerPlaylistBar::GetCurOMD(REFERENCE_TIME rtStart) if(fn.Find(_T("video_ts.ifo")) >= 0
|| fn.Find(_T(".ratdvd")) >= 0)
{
- if(OpenDVDData* p = new OpenDVDData())
+ if(OpenDVDData* p = DNew OpenDVDData())
{
p->path = pli.m_fns.GetHead();
p->subs.AddTailList(&pli.m_subs);
@@ -663,7 +684,7 @@ OpenMediaData* CPlayerPlaylistBar::GetCurOMD(REFERENCE_TIME rtStart) if(pli.m_type == CPlaylistItem::device)
{
- if(OpenDeviceData* p = new OpenDeviceData())
+ if(OpenDeviceData* p = DNew OpenDeviceData())
{
POSITION pos = pli.m_fns.GetHeadPosition();
for(int i = 0; i < countof(p->DisplayName) && pos; i++)
@@ -676,7 +697,7 @@ OpenMediaData* CPlayerPlaylistBar::GetCurOMD(REFERENCE_TIME rtStart) }
else
{
- if(OpenFileData* p = new OpenFileData())
+ if(OpenFileData* p = DNew OpenFileData())
{
p->fns.AddTailList(&pli.m_fns);
p->subs.AddTailList(&pli.m_subs);
diff --git a/src/apps/mplayerc/PlayerPlaylistBar.h b/src/apps/mplayerc/PlayerPlaylistBar.h index 3cadfc1ed..6d78a2203 100644 --- a/src/apps/mplayerc/PlayerPlaylistBar.h +++ b/src/apps/mplayerc/PlayerPlaylistBar.h @@ -48,6 +48,8 @@ private: void ParsePlayList(CString fn, CAtlList<CString>* subs);
void ParsePlayList(CAtlList<CString>& fns, CAtlList<CString>* subs);
+ bool ParseBDMVPlayList(CString fn);
+
bool ParseMPCPlayList(CString fn);
bool SaveMPCPlayList(CString fn, CTextFile::enc e, bool fRemovePath);
diff --git a/src/apps/mplayerc/PlayerSubresyncBar.cpp b/src/apps/mplayerc/PlayerSubresyncBar.cpp index 4d9d4a360..65c0f36d2 100644 --- a/src/apps/mplayerc/PlayerSubresyncBar.cpp +++ b/src/apps/mplayerc/PlayerSubresyncBar.cpp @@ -700,7 +700,7 @@ void CPlayerSubresyncBar::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult) fNeedsUpdate = true;
if(!m_sts.m_styles.Lookup(str))
- m_sts.AddStyle(str, new STSStyle());
+ m_sts.AddStyle(str, DNew STSStyle());
m_sts[pItem->iItem].style = str;
@@ -1001,7 +1001,7 @@ void CPlayerSubresyncBar::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult) STSStyle* val;
m_sts.m_styles.GetNextAssoc(pos, key, val);
- CAutoPtr<CPPageSubStyle> page(new CPPageSubStyle());
+ CAutoPtr<CPPageSubStyle> page(DNew CPPageSubStyle());
page->InitStyle(key, *val);
pages.Add(page);
styles.Add(val);
diff --git a/src/apps/mplayerc/RealMediaGraph.cpp b/src/apps/mplayerc/RealMediaGraph.cpp index fe45f4827..5cf7efeaa 100644 --- a/src/apps/mplayerc/RealMediaGraph.cpp +++ b/src/apps/mplayerc/RealMediaGraph.cpp @@ -101,7 +101,7 @@ bool CRealMediaPlayer::Init() if(!dllpaths.IsEmpty())
{
- char* s = new char[dllpaths.GetLength()+1];
+ char* s = DNew char[dllpaths.GetLength()+1];
strcpy(s, CStringA(dllpaths));
for(int i = 0, j = strlen(s); i < j; i++) {if(s[i] == '|') s[i] = '\0';}
m_fpSetDLLAccessPath(s);
@@ -521,7 +521,7 @@ bool CRealMediaPlayerWindowless::CreateSite(IRMASite** ppSite) CRealMediaWindowlessSite* pWMWlS;
CComPtr<IRMASiteWindowless> pSiteWindowless;
- pSiteWindowless = (IRMASiteWindowless*)(pWMWlS = new CRealMediaWindowlessSite(hr, m_pPlayer, NULL, NULL));
+ pSiteWindowless = (IRMASiteWindowless*)(pWMWlS = DNew CRealMediaWindowlessSite(hr, m_pPlayer, NULL, NULL));
if(FAILED(hr))
return(false);
@@ -557,8 +557,8 @@ CRealMediaGraph::CRealMediaGraph(HWND hWndParent, HRESULT& hr) hr = S_OK;
m_pRMP = AfxGetAppSettings().iRMVideoRendererType == VIDRNDT_RM_DEFAULT
- ? (CRealMediaPlayer*)new CRealMediaPlayerWindowed(hWndParent, this)
- : (CRealMediaPlayer*)new CRealMediaPlayerWindowless(hWndParent, this);
+ ? (CRealMediaPlayer*)DNew CRealMediaPlayerWindowed(hWndParent, this)
+ : (CRealMediaPlayer*)DNew CRealMediaPlayerWindowless(hWndParent, this);
if(!m_pRMP)
{
diff --git a/src/apps/mplayerc/RealMediaWindowlessSite.cpp b/src/apps/mplayerc/RealMediaWindowlessSite.cpp index 8504a7ec8..8cbd2900f 100644 --- a/src/apps/mplayerc/RealMediaWindowlessSite.cpp +++ b/src/apps/mplayerc/RealMediaWindowlessSite.cpp @@ -36,7 +36,7 @@ void DSObjects::ExtractRects(REGION* pRegion) DWORD sizeNeeed = GetRegionData((HRGN)pRegion->pOSRegion, 0, NULL);
- lpRgnData = (LPRGNDATA)new char[sizeNeeed];
+ lpRgnData = (LPRGNDATA)DNew char[sizeNeeed];
DWORD returnValue = GetRegionData((HRGN)pRegion->pOSRegion, sizeNeeed, lpRgnData);
PN_VECTOR_DELETE(pRegion->rects);
@@ -49,7 +49,7 @@ void DSObjects::ExtractRects(REGION* pRegion) if(lpRgnData->rdh.nCount)
{
- pRegion->rects = new PNxRect[lpRgnData->rdh.nCount];
+ pRegion->rects = DNew PNxRect[lpRgnData->rdh.nCount];
// now extract the information.
@@ -67,7 +67,7 @@ void DSObjects::ExtractRects(REGION* pRegion) }
REGION* DSObjects::RMACreateRectRegion(int left, int top, int right, int bottom)
{
- REGION* retVal = new REGION;
+ REGION* retVal = DNew REGION;
retVal->pOSRegion = (void*)CreateRectRgn(left, top, right, bottom);
ExtractRects(retVal);
return retVal;
@@ -366,7 +366,7 @@ STDMETHODIMP CRealMediaWindowlessSite::CreateChild(REF(IRMASite*) /*OUT*/ pChild HRESULT hr = PNR_OK;
CComPtr<IRMASite> pSite =
- (IRMASite*)new CRealMediaWindowlessSite(hr, m_pContext, this);
+ (IRMASite*)DNew CRealMediaWindowlessSite(hr, m_pContext, this);
if(FAILED(hr) || !pSite)
return E_FAIL;
diff --git a/src/apps/mplayerc/RegFilterChooserDlg.cpp b/src/apps/mplayerc/RegFilterChooserDlg.cpp index fffb76675..cb5eff761 100644 --- a/src/apps/mplayerc/RegFilterChooserDlg.cpp +++ b/src/apps/mplayerc/RegFilterChooserDlg.cpp @@ -130,7 +130,7 @@ void CRegFilterChooserDlg::OnBnClickedOk() if(pMoniker)
{
CFGFilterRegistry fgf(pMoniker);
- FilterOverride* f = new FilterOverride;
+ FilterOverride* f = DNew FilterOverride;
f->fDisabled = false;
f->type = FilterOverride::REGISTERED;
f->name = fgf.GetName();
diff --git a/src/apps/mplayerc/SaveDlg.cpp b/src/apps/mplayerc/SaveDlg.cpp index 457598232..13f3f6116 100644 --- a/src/apps/mplayerc/SaveDlg.cpp +++ b/src/apps/mplayerc/SaveDlg.cpp @@ -92,7 +92,7 @@ BOOL CSaveDlg::OnInitDialog() if(!pReader && m_in.Mid(m_in.ReverseFind('.')+1).MakeLower() == _T("cda"))
{
hr = S_OK;
- CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)new CCDDAReader(NULL, &hr);
+ CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CCDDAReader(NULL, &hr);
if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL)))
pReader.Release();
}
@@ -102,7 +102,7 @@ BOOL CSaveDlg::OnInitDialog() if(!pReader)
{
hr = S_OK;
- CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)new CCDXAReader(NULL, &hr);
+ CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CCDXAReader(NULL, &hr);
if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL)))
pReader.Release();
}
@@ -112,7 +112,7 @@ BOOL CSaveDlg::OnInitDialog() if(!pReader /*&& ext == _T("ifo")*/)
{
hr = S_OK;
- CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)new CVTSReader(NULL, &hr);
+ CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CVTSReader(NULL, &hr);
if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL)))
pReader.Release();
else
@@ -156,7 +156,7 @@ BOOL CSaveDlg::OnInitDialog() return FALSE;
}
- CComQIPtr<IBaseFilter> pMid = new CStreamDriveThruFilter(NULL, &hr);
+ CComQIPtr<IBaseFilter> pMid = DNew CStreamDriveThruFilter(NULL, &hr);
if(FAILED(pGB->AddFilter(pMid, L"StreamDriveThru")))
{
m_report.SetWindowText(_T("Error"));
diff --git a/src/apps/mplayerc/ShaderCombineDlg.cpp b/src/apps/mplayerc/ShaderCombineDlg.cpp index 43deeab3c..9c5ba5cdc 100644 --- a/src/apps/mplayerc/ShaderCombineDlg.cpp +++ b/src/apps/mplayerc/ShaderCombineDlg.cpp @@ -27,9 +27,10 @@ // CShaderCombineDlg dialog
-CShaderCombineDlg::CShaderCombineDlg(CAtlList<CString>& labels, CWnd* pParent /*=NULL*/)
+CShaderCombineDlg::CShaderCombineDlg(CAtlList<CString>& labels, CWnd* pParent , bool bScreenSpace)
: CResizableDialog(CShaderCombineDlg::IDD, pParent)
, m_labels(labels)
+ , m_bScreenSpace(bScreenSpace)
{
}
@@ -69,7 +70,11 @@ BOOL CShaderCombineDlg::OnInitDialog() AppSettings& s = AfxGetAppSettings();
- CString str = s.m_shadercombine.Trim();
+ CString str;
+ if (m_bScreenSpace)
+ str = s.m_shadercombineScreenSpace.Trim();
+ else
+ str = s.m_shadercombine.Trim();
CAtlList<CString> sl;
if(!str.IsEmpty()) Explode(str, sl, '|');
@@ -99,7 +104,10 @@ void CShaderCombineDlg::OnOK() m_labels.AddTail(label);
}
- AfxGetAppSettings().m_shadercombine = Implode(sl, '|');
+ if (m_bScreenSpace)
+ AfxGetAppSettings().m_shadercombineScreenSpace = Implode(sl, '|');
+ else
+ AfxGetAppSettings().m_shadercombine = Implode(sl, '|');
__super::OnOK();
}
diff --git a/src/apps/mplayerc/ShaderCombineDlg.h b/src/apps/mplayerc/ShaderCombineDlg.h index 6c7f859eb..f464fff75 100644 --- a/src/apps/mplayerc/ShaderCombineDlg.h +++ b/src/apps/mplayerc/ShaderCombineDlg.h @@ -31,9 +31,10 @@ class CShaderCombineDlg : public CResizableDialog
{
CAtlList<CString>& m_labels;
+ bool m_bScreenSpace;
public:
- CShaderCombineDlg(CAtlList<CString>& labels, CWnd* pParent = NULL); // standard constructor
+ CShaderCombineDlg(CAtlList<CString>& labels, CWnd* pParent, bool bScreenSpace); // standard constructor
virtual ~CShaderCombineDlg();
// Dialog Data
diff --git a/src/apps/mplayerc/ShaderEditorDlg.cpp b/src/apps/mplayerc/ShaderEditorDlg.cpp index b6f0402cd..5e8b9ec89 100644 --- a/src/apps/mplayerc/ShaderEditorDlg.cpp +++ b/src/apps/mplayerc/ShaderEditorDlg.cpp @@ -408,7 +408,7 @@ void CShaderEditorDlg::OnTimer(UINT_PTR nIDEvent) m_pShader->srcdata = srcdata;
m_pShader->target = target;
- if(!m_pPSC) m_pPSC = new CPixelShaderCompiler(NULL);
+ if(!m_pPSC) m_pPSC = DNew CPixelShaderCompiler(NULL);
CString disasm, errmsg;
HRESULT hr = m_pPSC->CompileShader(CStringA(srcdata), "main", CStringA(target), D3DXSHADER_DEBUG, NULL, &disasm, &errmsg);
diff --git a/src/apps/mplayerc/StdAfx.h b/src/apps/mplayerc/StdAfx.h index f318bc65b..323b94595 100644 --- a/src/apps/mplayerc/StdAfx.h +++ b/src/apps/mplayerc/StdAfx.h @@ -30,6 +30,7 @@ #if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
+#include "..\..\DSUtil\SharedInclude.h"
// VS2005 changed result of OnNCHitTest
#if _MSC_VER >= 1400
@@ -76,6 +77,8 @@ template <class T = CString, class S = CString>
class CAtlStringMap : public CAtlMap<S, T, CStringElementTraits<S> > {};
+
+
//#define BCM_SETSHIELD 0x0000160C // Shield style for button (elevated privilege)
//{{AFX_INSERT_LOCATION}}
diff --git a/src/apps/mplayerc/TextPassThruFilter.cpp b/src/apps/mplayerc/TextPassThruFilter.cpp index 53f14b7d3..453dcd522 100644 --- a/src/apps/mplayerc/TextPassThruFilter.cpp +++ b/src/apps/mplayerc/TextPassThruFilter.cpp @@ -188,8 +188,8 @@ CTextPassThruFilter::CTextPassThruFilter(CMainFrame* pMainFrame) , m_pMainFrame(pMainFrame)
{
HRESULT hr;
- m_pInput = new CTextPassThruInputPin(this, this, &m_pMainFrame->m_csSubLock, &hr);
- m_pOutput = new CTextPassThruOutputPin(this, this, &hr);
+ m_pInput = DNew CTextPassThruInputPin(this, this, &m_pMainFrame->m_csSubLock, &hr);
+ m_pOutput = DNew CTextPassThruOutputPin(this, this, &hr);
}
CTextPassThruFilter::~CTextPassThruFilter()
diff --git a/src/apps/mplayerc/VMROSD.cpp b/src/apps/mplayerc/VMROSD.cpp index 5d3b7adc4..69a9800ef 100644 --- a/src/apps/mplayerc/VMROSD.cpp +++ b/src/apps/mplayerc/VMROSD.cpp @@ -50,6 +50,7 @@ CVMROSD::CVMROSD(void) m_bCursorMoving = false;
m_pMFVMB = NULL;
m_pVMB = NULL;
+ memset(&m_BitmapInfo, 0, sizeof(m_BitmapInfo));
}
CVMROSD::~CVMROSD(void)
@@ -75,12 +76,14 @@ void CVMROSD::OnSize(UINT nType, int cx, int cy) void CVMROSD::UpdateBitmap()
{
+ CAutoLock Lock(&m_Lock);
CRect rc;
CWindowDC dc (m_pWnd);
CalcRect();
m_MemDC.DeleteDC();
+ memset(&m_BitmapInfo, 0, sizeof(m_BitmapInfo));
if (m_MemDC.CreateCompatibleDC (&dc))
{
@@ -215,6 +218,8 @@ void CVMROSD::DrawSlider(CRect* rect, __int64 llMin, __int64 llMax, __int64 llPo void CVMROSD::DrawMessage()
{
+ if (m_BitmapInfo.bmWidth*m_BitmapInfo.bmHeight*(m_BitmapInfo.bmBitsPixel/8) == 0)
+ return;
if (m_nMessagePos != OSD_NOMESSAGE)
{
CRect rectText (0,0,0,0);
@@ -239,6 +244,9 @@ void CVMROSD::DrawMessage() void CVMROSD::Invalidate()
{
+ CAutoLock Lock(&m_Lock);
+ if (m_BitmapInfo.bmWidth*m_BitmapInfo.bmHeight*(m_BitmapInfo.bmBitsPixel/8) == 0)
+ return;
memsetd(m_BitmapInfo.bmBits, 0xff000000, m_BitmapInfo.bmWidth*m_BitmapInfo.bmHeight*(m_BitmapInfo.bmBitsPixel/8));
if (m_bSeekBarVisible) DrawSlider(&m_rectSeekBar, m_llSeekMin, m_llSeekMax, m_llSeekPos);
@@ -284,6 +292,12 @@ bool CVMROSD::OnMouseMove(UINT nFlags, CPoint point) else if (m_bSeekBarVisible && !m_rectSeekBar.PtInRect(point))
{
m_bSeekBarVisible = false;
+ // Add new timer for removing any messages
+ if (m_pWnd)
+ {
+ KillTimer(m_pWnd->m_hWnd, (long)this);
+ SetTimer(m_pWnd->m_hWnd, (long)this, 1000, (TIMERPROC)TimerFunc);
+ }
Invalidate();
}
else
@@ -356,10 +370,14 @@ void CVMROSD::TimerFunc(HWND hWnd, UINT nMsg, UINT nIDEvent, DWORD dwTime) {
pVMROSD->ClearMessage();
}
+ KillTimer(hWnd, nIDEvent);
}
void CVMROSD::ClearMessage()
{
+ CAutoLock Lock(&m_Lock);
+ if (m_bSeekBarVisible)
+ return;
if (m_pVMB)
{
DWORD dwBackup = (m_VMR9AlphaBitmap.dwFlags | VMRBITMAP_DISABLE);
diff --git a/src/apps/mplayerc/VMROSD.h b/src/apps/mplayerc/VMROSD.h index 7495e64cb..143edb0b3 100644 --- a/src/apps/mplayerc/VMROSD.h +++ b/src/apps/mplayerc/VMROSD.h @@ -75,6 +75,7 @@ private : CComPtr<IMFVideoMixerBitmap> m_pMFVMB;
CWnd* m_pWnd;
+ CCritSec m_Lock;
CDC m_MemDC;
VMR9AlphaBitmap m_VMR9AlphaBitmap;
MFVideoAlphaBitmap m_MFVideoAlphaBitmap;
diff --git a/src/apps/mplayerc/WebServer.cpp b/src/apps/mplayerc/WebServer.cpp index 7b990d2e0..7b8bbe1bd 100644 --- a/src/apps/mplayerc/WebServer.cpp +++ b/src/apps/mplayerc/WebServer.cpp @@ -271,7 +271,7 @@ bool CWebServer::LoadPage(UINT resid, CStringA& str, CString path) void CWebServer::OnAccept(CWebServerSocket* pServer)
{
- CAutoPtr<CWebClientSocket> p(new CWebClientSocket(this, m_pMainFrame));
+ CAutoPtr<CWebClientSocket> p(DNew CWebClientSocket(this, m_pMainFrame));
if(pServer->Accept(*p))
{
CString name;
@@ -581,7 +581,7 @@ bool CWebServer::CallCGI(CWebClientSocket* pClient, CStringA& hdr, CStringA& bod FreeEnvironmentStrings((LPTSTR)lpvEnv);
}
- TCHAR* cmdln = new TCHAR[32768];
+ TCHAR* cmdln = DNew TCHAR[32768];
_sntprintf(cmdln, 32768, _T("\"%s\" \"%s\""), cgi, path);
if(hChildStdinRd && hChildStdoutWr)
diff --git a/src/apps/mplayerc/build - clean.bat b/src/apps/mplayerc/build - clean.bat new file mode 100644 index 000000000..d441098f9 --- /dev/null +++ b/src/apps/mplayerc/build - clean.bat @@ -0,0 +1,2 @@ +call build.bat clean
+pause
diff --git a/src/apps/mplayerc/build - normal.bat b/src/apps/mplayerc/build - normal.bat new file mode 100644 index 000000000..e377ab84d --- /dev/null +++ b/src/apps/mplayerc/build - normal.bat @@ -0,0 +1,3 @@ +
+call build.bat
+pause
diff --git a/src/apps/mplayerc/build.bat b/src/apps/mplayerc/build.bat new file mode 100644 index 000000000..c3605e107 --- /dev/null +++ b/src/apps/mplayerc/build.bat @@ -0,0 +1,120 @@ +@echo off
+
+IF "%VS90COMNTOOLS%"=="" goto BadPaths
+IF "%MINGW32%"=="" goto BadPaths
+IF "%MINGW64%"=="" goto BadPaths
+IF "%MINGW32_GCCLIB%"=="" goto BadPaths
+IF "%MINGW64_GCCLIB%"=="" goto BadPaths
+goto GoodPaths
+
+:BadPaths
+echo "Not all build dependencies found. To build you need:"
+echo "* Visual Studio 2008 installed"
+echo "* MinGW 32 bit build environment with coreMSYS pointed to in MINGW32 env var"
+echo "* MinGW 64 bit build environment with coreMSYS pointed to in MINGW64 env var"
+echo "* MinGW 32 bit gcc library directory pointed to in MINGW32_GCCLIB env var"
+echo "* MinGW 64 bit gcc library directory pointed to in MINGW64_GCCLIB env var"
+pause
+goto EndGood
+
+:GoodPaths
+SET BUILDTYPE=/%1
+IF "%1"=="" set BUILDTYPE=/build
+
+SET ORIGPATH="%CD%"
+call "%VS90COMNTOOLS%vsvars32.bat"
+cd %ORIGPATH%
+
+devenv ../../../mpc-hc.sln %BUILDTYPE% "Release Unicode|Win32"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+
+devenv mpciconlib.sln %BUILDTYPE% "Release Unicode|Win32"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Chinese simplified|Win32"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Chinese traditional|Win32"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Czech|Win32"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode French|Win32"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode German|Win32"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Hungarian|Win32"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Italian|Win32"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Korean|Win32"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Polish|Win32"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Russian|Win32"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Slovak|Win32"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Spanish|Win32"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Turkish|Win32"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Ukrainian|Win32"
+
+mkdir Build_x86
+xcopy "Release Unicode\*.dll" ".\Build_x86\" /y
+xcopy "Release Unicode\*.exe" ".\Build_x86\" /y
+xcopy AUTHORS ".\Build_x86\" /y
+xcopy ChangeLog ".\Build_x86\" /y
+xcopy Homepage.url ".\Build_x86\" /y
+xcopy ..\..\..\COPYING ".\Build_x86\" /y
+
+rem goto Nox64
+devenv ..\..\..\mpc-hc.sln %BUILDTYPE% "Release Unicode|x64"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpciconlib.sln %BUILDTYPE% "Release Unicode|x64"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Chinese simplified|x64"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Chinese traditional|x64"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Czech|x64"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode French|x64"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode German|x64"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Hungarian|x64"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Italian|x64"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Korean|x64"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Polish|x64"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Russian|x64"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Slovak|x64"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Spanish|x64"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Turkish|x64"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+devenv mpcresources.sln %BUILDTYPE% "Release Unicode Ukrainian|x64"
+IF %ERRORLEVEL% NEQ 0 GOTO EndBad
+
+mkdir Build_x64
+xcopy "x64\Release Unicode\*.dll" ".\Build_x64\" /y
+xcopy "x64\Release Unicode\*.exe" ".\Build_x64\" /y
+xcopy AUTHORS ".\Build_x64\" /y
+xcopy ChangeLog ".\Build_x64\" /y
+xcopy Homepage.url ".\Build_x64\" /y
+xcopy ..\..\..\COPYING ".\Build_x64\" /y
+
+:Nox64
+
+goto EndGood
+
+:EndBad
+echo " "
+echo ERROR: Build failed and aborted
+pause
+
+:EndGood
diff --git a/src/apps/mplayerc/jpeg.cpp b/src/apps/mplayerc/jpeg.cpp index 39c50f4b8..6488b394f 100644 --- a/src/apps/mplayerc/jpeg.cpp +++ b/src/apps/mplayerc/jpeg.cpp @@ -300,13 +300,13 @@ bool CJpegEncoder::Encode(const BYTE* dib) m_w = bi->bmiHeader.biWidth;
m_h = abs(bi->bmiHeader.biHeight);
- m_p = new BYTE[m_w*m_h*4];
+ m_p = DNew BYTE[m_w*m_h*4];
const BYTE* src = dib + sizeof(bi->bmiHeader);
if(bi->bmiHeader.biBitCount <= 8)
{
if(bi->bmiHeader.biClrUsed) src += bi->bmiHeader.biClrUsed * sizeof(bi->bmiColors[0]);
- else src += (1 << bi->bmiHeader.biBitCount) * sizeof(bi->bmiColors[0]);
+ else src += (1 << bi->bmiHeader.biBitCount) * DWORD(sizeof(bi->bmiColors[0]));
}
int srcpitch = m_w*(bpp>>3);
diff --git a/src/apps/mplayerc/libpng.c b/src/apps/mplayerc/libpng.c index 82e15960e..14b987896 100644 --- a/src/apps/mplayerc/libpng.c +++ b/src/apps/mplayerc/libpng.c @@ -45,8 +45,8 @@ unsigned char* DecompressPNG(struct png_t* png, int* w, int* h) unsigned char* row;
unsigned int x, y, c;
- if(png_sig_cmp(png->data, 0, 8) != 0) - return NULL; + if(png_sig_cmp(png->data, 0, 8) != 0)
+ return NULL;
png->pos = 8;
@@ -57,25 +57,25 @@ unsigned char* DecompressPNG(struct png_t* png, int* w, int* h) png_set_read_fn(png_ptr, (png_voidp)png, read_data_fn);
- info_ptr = png_create_info_struct(png_ptr); - if(!info_ptr) - { - png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL); - return NULL; - } -
- end_info = png_create_info_struct(png_ptr); - if(!end_info) - { - png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); - return NULL; - } -
- if(setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - return NULL; - } + info_ptr = png_create_info_struct(png_ptr);
+ if(!info_ptr)
+ {
+ png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
+ return NULL;
+ }
+
+ end_info = png_create_info_struct(png_ptr);
+ if(!end_info)
+ {
+ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
+ return NULL;
+ }
+
+ if(setjmp(png_jmpbuf(png_ptr)))
+ {
+ png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
+ return NULL;
+ }
png_set_sig_bytes(png_ptr, 8);
@@ -90,7 +90,7 @@ unsigned char* DecompressPNG(struct png_t* png, int* w, int* h) if(png_get_channels(png_ptr, info_ptr) != 3)
{
- png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); + png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
return NULL;
}
diff --git a/src/apps/mplayerc/mpciconlib.cpp b/src/apps/mplayerc/mpciconlib.cpp index 75c706f4c..2c1bf66a5 100644 --- a/src/apps/mplayerc/mpciconlib.cpp +++ b/src/apps/mplayerc/mpciconlib.cpp @@ -51,6 +51,7 @@ int get_icon_index(CString ext) else if(ext.CompareNoCase(_T(".m2ts")) == 0) iconindex = IDI_MPG_ICON;
else if(ext.CompareNoCase(_T(".m2v")) == 0) iconindex = IDI_MPG_ICON;
else if(ext.CompareNoCase(_T(".m3u")) == 0) iconindex = IDI_PLS_ICON;
+ else if(ext.CompareNoCase(_T(".bdmv")) == 0) iconindex = IDI_PLS_ICON;
else if(ext.CompareNoCase(_T(".m4a")) == 0) iconindex = IDI_AAC_ICON;
else if(ext.CompareNoCase(_T(".m4b")) == 0) iconindex = IDI_AAC_ICON;
else if(ext.CompareNoCase(_T(".m4v")) == 0) iconindex = IDI_MP4_ICON;
diff --git a/src/apps/mplayerc/mpciconlib.sln b/src/apps/mplayerc/mpciconlib.sln new file mode 100644 index 000000000..632e0b463 --- /dev/null +++ b/src/apps/mplayerc/mpciconlib.sln @@ -0,0 +1,20 @@ +
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpciconlib", "mpciconlib_2005.vcproj", "{86251DC4-9298-424C-AE6C-07844F79C0B5}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Release Unicode|Win32 = Release Unicode|Win32
+ Release Unicode|x64 = Release Unicode|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {86251DC4-9298-424C-AE6C-07844F79C0B5}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32
+ {86251DC4-9298-424C-AE6C-07844F79C0B5}.Release Unicode|Win32.Build.0 = Release Unicode|Win32
+ {86251DC4-9298-424C-AE6C-07844F79C0B5}.Release Unicode|x64.ActiveCfg = Release Unicode|x64
+ {86251DC4-9298-424C-AE6C-07844F79C0B5}.Release Unicode|x64.Build.0 = Release Unicode|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/src/apps/mplayerc/mpciconlib_2005.vcproj b/src/apps/mplayerc/mpciconlib_2005.vcproj index e1de90018..6682943ee 100644 --- a/src/apps/mplayerc/mpciconlib_2005.vcproj +++ b/src/apps/mplayerc/mpciconlib_2005.vcproj @@ -1,11 +1,12 @@ <?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="8,00"
+ Version="9.00"
Name="mpciconlib"
ProjectGUID="{86251DC4-9298-424C-AE6C-07844F79C0B5}"
RootNamespace="mpciconlib"
Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
@@ -71,6 +72,8 @@ SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
@@ -135,6 +138,8 @@ Name="VCLinkerTool"
OutputFile="$(OutDir)\$(ProjectName).dll"
ModuleDefinitionFile=".\mpciconlib.def"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
/>
<Tool
Name="VCALinkTool"
diff --git a/src/apps/mplayerc/mplayerc.by.rc b/src/apps/mplayerc/mplayerc.by.rc Binary files differindex 745fa105d..9d4e7de35 100644 --- a/src/apps/mplayerc/mplayerc.by.rc +++ b/src/apps/mplayerc/mplayerc.by.rc diff --git a/src/apps/mplayerc/mplayerc.cpp b/src/apps/mplayerc/mplayerc.cpp index e0f15a090..0fcc8f79d 100644 --- a/src/apps/mplayerc/mplayerc.cpp +++ b/src/apps/mplayerc/mplayerc.cpp @@ -35,6 +35,7 @@ #include "Ifo.h"
#include "MiniDump.h"
+#pragma comment(lib, "winmm.lib")
/////////
#define IDS_RS_ENABLEEDLEDITOR _T("EnableEDLEditor")
@@ -702,7 +703,7 @@ public: spd.pitch = spd.w*spd.bpp>>3;
spd.type = MSP_RGB32;
spd.vidrect = CRect(0, 0, spd.w, spd.h);
- spd.bits = new BYTE[spd.pitch*spd.h];
+ spd.bits = DNew BYTE[spd.pitch*spd.h];
CCritSec csLock;
/*
@@ -955,7 +956,7 @@ BOOL CMPlayerCApp::InitInstance() AfxEnableControlContainer();
- CMainFrame* pFrame = new CMainFrame;
+ CMainFrame* pFrame = DNew CMainFrame;
m_pMainWnd = pFrame;
pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW|FWS_ADDTOTITLE, NULL, NULL);
pFrame->SetDefaultWindowRect((m_s.nCLSwitches&CLSW_MONITOR)?m_s.iMonitor:0);
@@ -1361,12 +1362,18 @@ void CMPlayerCApp::Settings::CreateCommands() ADDCMD((ID_VIEW_TEARING_TEST, 'T', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TEARING_TEST));
ADDCMD((ID_VIEW_REMAINING_TIME, 'I', FVIRTKEY|FCONTROL|FNOINVERT, IDS_MPLAYERC_98));
ADDCMD((ID_SHADER_TOGGLE, 'P', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AT_TOGGLE_SHADER));
+ ADDCMD((ID_SHADER_TOGGLESCREENSPACE, 'P', FVIRTKEY|FCONTROL|FALT|FNOINVERT, IDS_AT_TOGGLE_SHADERSCREENSPACE));
ADDCMD((ID_D3DFULLSCREEN_TOGGLE, 'F', FVIRTKEY|FCONTROL|FNOINVERT, IDS_MPLAYERC_99));
ADDCMD((ID_GOTO_PREV_SUB, 'Y', FVIRTKEY|FNOINVERT, IDS_MPLAYERC_100, APPCOMMAND_BROWSER_BACKWARD));
ADDCMD((ID_GOTO_NEXT_SUB, 'U', FVIRTKEY|FNOINVERT, IDS_MPLAYERC_101, APPCOMMAND_BROWSER_FORWARD));
ADDCMD((ID_SHIFT_SUB_DOWN, VK_NEXT, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_102));
ADDCMD((ID_SHIFT_SUB_UP, VK_PRIOR, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_103));
- ADDCMD((ID_VIEW_DISPLAYSTATS, 'J', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_DISPLAY_STATS));
+ ADDCMD((ID_VIEW_DISPLAYSTATS_SC, 'J', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_DISPLAY_STATS));
+ ADDCMD((ID_VIEW_VSYNC, 'V', FVIRTKEY|FNOINVERT, IDS_AG_VSYNC));
+ ADDCMD((ID_VIEW_ENABLEFRAMETIMECORRECTION, 'C', FVIRTKEY|FNOINVERT, IDS_AG_ENABLEFRAMETIMECORRECTION));
+ ADDCMD((ID_VIEW_VSYNCACCURATE, 'V', FVIRTKEY|FCONTROL|FALT|FNOINVERT, IDS_AG_VSYNCACCURATE));
+ ADDCMD((ID_VIEW_VSYNCOFFSET_DECREASE, VK_UP, FVIRTKEY|FCONTROL|FALT|FNOINVERT, IDS_AG_VSYNCOFFSET_DECREASE));
+ ADDCMD((ID_VIEW_VSYNCOFFSET_INCREASE, VK_DOWN, FVIRTKEY|FCONTROL|FALT|FNOINVERT, IDS_AG_VSYNCOFFSET_INCREASE));
ADDCMD((ID_SUB_DELAY_DOWN, VK_F1, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_104));
ADDCMD((ID_SUB_DELAY_UP, VK_F2, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_105));
ADDCMD((ID_FILE_SAVE_THUMBNAILS, 0, FVIRTKEY|FNOINVERT, IDS_FILE_SAVE_THUMBNAILS));
@@ -1538,10 +1545,25 @@ void CMPlayerCApp::Settings::UpdateData(bool fSave) pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_RMVIDEORENDERERTYPE), iRMVideoRendererType);
pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_QTVIDEORENDERERTYPE), iQTVideoRendererType);
pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_APSURACEFUSAGE), iAPSurfaceUsage);
- pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_VMRSYNCFIX), fVMRSyncFix);
+// pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_VMRSYNCFIX), fVMRSyncFix);
pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_DX9_RESIZER), iDX9Resizer);
pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_VMR9MIXERMODE), fVMR9MixerMode);
pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_VMR9MIXERYUV), fVMR9MixerYUV);
+ pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), _T("VMRAlternateVSync"), m_RenderSettings.fVMR9AlterativeVSync);
+ pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), _T("VMRVSyncOffset"), m_RenderSettings.iVMR9VSyncOffset);
+ pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), _T("VMRVSyncAccurate2"), m_RenderSettings.iVMR9VSyncAccurate);
+ pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), _T("VMRFullscreenGUISupport"), m_RenderSettings.iVMR9FullscreenGUISupport);
+ pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), _T("VMRVSync"), m_RenderSettings.iVMR9VSync);
+ pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), _T("VMRDisableDesktopComposition"), m_RenderSettings.iVMRDisableDesktopComposition);
+
+ pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), _T("EVROutputRange"), m_RenderSettings.iEVROutputRange);
+ pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), _T("EVRHighColorRes"), m_RenderSettings.iEVRHighColorResolution);
+ pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), _T("EVREnableFrameTimeCorrection"), m_RenderSettings.iEVREnableFrameTimeCorrection);
+
+ pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), _T("VMRFlushGPUBeforeVSync"), m_RenderSettings.iVMRFlushGPUBeforeVSync);
+ pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), _T("VMRFlushGPUAfterPresent"), m_RenderSettings.iVMRFlushGPUAfterPresent);
+ pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), _T("VMRFlushGPUWait"), m_RenderSettings.iVMRFlushGPUWait);
+
pApp->WriteProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AUDIORENDERERTYPE), CString(AudioRendererDisplayName));
pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AUTOLOADAUDIO), fAutoloadAudio);
pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AUTOLOADSUBTITLES), fAutoloadSubtitles);
@@ -1562,6 +1584,7 @@ void CMPlayerCApp::Settings::UpdateData(bool fSave) pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SPCMAXRES), nSPCMaxRes);
pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SUBDELAYINTERVAL), nSubDelayInterval);
pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_POW2TEX), fSPCPow2Tex);
+ pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), _T("SPCDisabeAnim"), fSPCDisableAnim);
pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ENABLESUBTITLES), fEnableSubtitles);
pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ENABLEAUDIOSWITCHER), fEnableAudioSwitcher);
pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ENABLEAUDIOTIMESHIFT), fAudioTimeShift);
@@ -1598,6 +1621,7 @@ void CMPlayerCApp::Settings::UpdateData(bool fSave) pApp->WriteProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_COLOR_SATURATION), strTemp);
pApp->WriteProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SHADERLIST), strShaderList);
+ pApp->WriteProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SHADERLISTSCREENSPACE), strShaderListScreenSpace);
pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_EVR_BUFFERS), iEvrBuffers);
pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SHOWOSD), (int)fShowOSD);
pApp->WriteProfileInt(ResStr(IDS_R_SETTINGS), IDS_RS_ENABLEEDLEDITOR, (int)fEnableEDLEditor);
@@ -1775,6 +1799,8 @@ void CMPlayerCApp::Settings::UpdateData(bool fSave) pApp->WriteProfileString(_T("Shaders"), NULL, NULL);
pApp->WriteProfileInt(_T("Shaders"), _T("Initialized"), 1);
pApp->WriteProfileString(_T("Shaders"), _T("Combine"), m_shadercombine);
+ pApp->WriteProfileString(_T("Shaders"), _T("CombineScreenSpace"), m_shadercombineScreenSpace);
+
pos = m_shaders.GetHeadPosition();
for(int i = 0; pos; i++)
@@ -1844,10 +1870,26 @@ void CMPlayerCApp::Settings::UpdateData(bool fSave) iRMVideoRendererType = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_RMVIDEORENDERERTYPE), VIDRNDT_RM_DEFAULT);
iQTVideoRendererType = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_QTVIDEORENDERERTYPE), VIDRNDT_QT_DEFAULT);
iAPSurfaceUsage = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_APSURACEFUSAGE), (IsVistaOrAbove() ? VIDRNDT_AP_TEXTURE3D : VIDRNDT_AP_TEXTURE2D));
- fVMRSyncFix = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_VMRSYNCFIX), FALSE);
+// fVMRSyncFix = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_VMRSYNCFIX), FALSE);
iDX9Resizer = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_DX9_RESIZER), 1);
fVMR9MixerMode = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_VMR9MIXERMODE), TRUE);
fVMR9MixerYUV = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_VMR9MIXERYUV), FALSE);
+ CRendererSettingsEVR DefaultSettings;
+ m_RenderSettings.fVMR9AlterativeVSync = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), _T("VMRAlternateVSync"), DefaultSettings.fVMR9AlterativeVSync);
+ m_RenderSettings.iVMR9VSyncOffset = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), _T("VMRVSyncOffset"), DefaultSettings.iVMR9VSyncOffset);
+ m_RenderSettings.iVMR9VSyncAccurate = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), _T("VMRVSyncAccurate2"), DefaultSettings.iVMR9VSyncAccurate);
+ m_RenderSettings.iVMR9FullscreenGUISupport = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), _T("VMRFullscreenGUISupport"), DefaultSettings.iVMR9FullscreenGUISupport);
+ m_RenderSettings.iEVRHighColorResolution = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), _T("EVRHighColorRes"), DefaultSettings.iEVRHighColorResolution);
+ m_RenderSettings.iEVREnableFrameTimeCorrection = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), _T("EVREnableFrameTimeCorrection"), DefaultSettings.iEVREnableFrameTimeCorrection);
+ m_RenderSettings.iVMR9VSync = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), _T("VMRVSync"), DefaultSettings.iVMR9VSync);
+ m_RenderSettings.iVMRDisableDesktopComposition = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), _T("VMRDisableDesktopComposition"), DefaultSettings.iVMRDisableDesktopComposition);
+
+ m_RenderSettings.iEVROutputRange = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), _T("EVROutputRange"), DefaultSettings.iEVROutputRange);
+
+ m_RenderSettings.iVMRFlushGPUBeforeVSync = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), _T("VMRFlushGPUBeforeVSync"), DefaultSettings.iVMRFlushGPUBeforeVSync);
+ m_RenderSettings.iVMRFlushGPUAfterPresent = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), _T("VMRFlushGPUAfterPresent"), DefaultSettings.iVMRFlushGPUAfterPresent);
+ m_RenderSettings.iVMRFlushGPUWait = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), _T("VMRFlushGPUWait"), DefaultSettings.iVMRFlushGPUWait);
+
AudioRendererDisplayName = pApp->GetProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AUDIORENDERERTYPE), _T(""));
fAutoloadAudio = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AUTOLOADAUDIO), TRUE);
fAutoloadSubtitles = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_AUTOLOADSUBTITLES), IsVistaOrAbove() || !IsVSFilterInstalled() );
@@ -1912,6 +1954,15 @@ void CMPlayerCApp::Settings::UpdateData(bool fSave) nSPCMaxRes = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SPCMAXRES), 2);
nSubDelayInterval = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SUBDELAYINTERVAL), 500);
fSPCPow2Tex = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_POW2TEX), TRUE);
+
+ bool bDisableAnim = false;
+ SYSTEM_INFO SysInfo;
+ GetSystemInfo(&SysInfo);
+ if (SysInfo.dwNumberOfProcessors < 3)
+ bDisableAnim = true;
+
+
+ fSPCDisableAnim = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), _T("SPCDisabeAnim"), bDisableAnim);
fEnableSubtitles = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ENABLESUBTITLES), TRUE);
fEnableAudioSwitcher = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ENABLEAUDIOSWITCHER), TRUE);
fAudioTimeShift = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_ENABLEAUDIOTIMESHIFT), 0);
@@ -1958,7 +2009,7 @@ void CMPlayerCApp::Settings::UpdateData(bool fSave) CString key;
key.Format(_T("%s\\%04d"), ResStr(IDS_R_FILTERS), i);
- CAutoPtr<FilterOverride> f(new FilterOverride);
+ CAutoPtr<FilterOverride> f(DNew FilterOverride);
f->fDisabled = !pApp->GetProfileInt(key, _T("Enabled"), 0);
@@ -2145,6 +2196,7 @@ void CMPlayerCApp::Settings::UpdateData(bool fSave) shaders[_T("16-235 -> 0-255 [SD][HD]")] = IDF_SHADER_LEVELS;
shaders[_T("16-235 -> 0-255 [SD]")] = IDF_SHADER_LEVELS2;
+ shaders[_T("0-255 -> 16-235")] = IDF_SHADER_LEVELS3;
shaders[_T("BT.601 -> BT.709")] = IDF_SHADER_BT601_BT709;
shaders[_T("contour")] = IDF_SHADER_CONTOUR;
shaders[_T("deinterlace (blend)")] = IDF_SHADER_DEINTERLACE;
@@ -2226,6 +2278,7 @@ void CMPlayerCApp::Settings::UpdateData(bool fSave) dHue = (float)_tstof(pApp->GetProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_COLOR_HUE), _T("0")));
dSaturation = (float)_tstof(pApp->GetProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_COLOR_SATURATION), _T("1")));
strShaderList = pApp->GetProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SHADERLIST), _T(""));
+ strShaderListScreenSpace = pApp->GetProfileString(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SHADERLISTSCREENSPACE), _T(""));
iEvrBuffers = pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_EVR_BUFFERS), 5);
fShowOSD = !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), ResStr(IDS_RS_SHOWOSD), 1);
fEnableEDLEditor= !!pApp->GetProfileInt(ResStr(IDS_R_SETTINGS), IDS_RS_ENABLEEDLEDITOR, FALSE);
@@ -2271,6 +2324,8 @@ void CMPlayerCApp::Settings::UpdateData(bool fSave) // TODO: sort shaders by label
m_shadercombine = pApp->GetProfileString(_T("Shaders"), _T("Combine"), _T(""));
+ m_shadercombineScreenSpace = pApp->GetProfileString(_T("Shaders"), _T("CombineScreenSpace"), _T(""));
+
fInitialized = true;
}
}
@@ -2502,7 +2557,7 @@ void CMPlayerCApp::Settings::CRecentFileAndURLList::Add(LPCTSTR lpszPathName) // fully qualify the path name
TCHAR szTemp[1024];
- if(fURL) _tcscpy(szTemp, lpszPathName);
+ if(fURL) _tcscpy_s(szTemp, lpszPathName);
else AfxFullPath(szTemp, lpszPathName);
// update the MRU list, if an existing MRU string matches file name
@@ -2815,6 +2870,7 @@ CString GetContentType(CString fn, CAtlList<CString>* redir) else if(ext == _T(".m3u")) ct = _T("audio/x-mpegurl");
else if(ext == _T(".qtl")) ct = _T("application/x-quicktimeplayer");
else if(ext == _T(".mpcpl")) ct = _T("application/x-mpc-playlist");
+ else if(ext == _T(".bdmv")) ct = _T("application/x-bdmv-playlist");
if(FILE* f = _tfopen(fn, _T("rb")))
{
@@ -2843,18 +2899,18 @@ CString GetContentType(CString fn, CAtlList<CString>* redir) if(ct == _T("video/x-ms-asf"))
{
// ...://..."/>
- re.Attach(new CAtlRegExpT());
+ re.Attach(DNew CAtlRegExpT());
if(re && REPARSE_ERROR_OK == re->Parse(_T("{[a-zA-Z]+://[^\n\">]*}"), FALSE))
res.AddTail(re);
// Ref#n= ...://...\n
- re.Attach(new CAtlRegExpT());
+ re.Attach(DNew CAtlRegExpT());
if(re && REPARSE_ERROR_OK == re->Parse(_T("Ref\\z\\b*=\\b*[\"]*{([a-zA-Z]+://[^\n\"]+}"), FALSE))
res.AddTail(re);
}
else if(ct == _T("audio/x-scpls"))
{
// File1=...\n
- re.Attach(new CAtlRegExp<>());
+ re.Attach(DNew CAtlRegExp<>());
if(re && REPARSE_ERROR_OK == re->Parse(_T("file\\z\\b*=\\b*[\"]*{[^\n\"]+}"), FALSE))
res.AddTail(re);
}
@@ -2862,14 +2918,14 @@ CString GetContentType(CString fn, CAtlList<CString>* redir) {
// #comment
// ...
- re.Attach(new CAtlRegExp<>());
+ re.Attach(DNew CAtlRegExp<>());
if(re && REPARSE_ERROR_OK == re->Parse(_T("{[^#][^\n]+}"), FALSE))
res.AddTail(re);
}
else if(ct == _T("audio/x-pn-realaudio"))
{
// rtsp://...
- re.Attach(new CAtlRegExp<>());
+ re.Attach(DNew CAtlRegExp<>());
if(re && REPARSE_ERROR_OK == re->Parse(_T("{rtsp://[^\n]+}"), FALSE))
res.AddTail(re);
}
@@ -2891,8 +2947,7 @@ LONGLONG CMPlayerCApp::GetPerfCounter() if (m_PerfFrequency != 0)
{
QueryPerformanceCounter ((LARGE_INTEGER*)&i64Ticks100ns);
- i64Ticks100ns = i64Ticks100ns * 10000000;
- i64Ticks100ns = i64Ticks100ns / m_PerfFrequency;
+ i64Ticks100ns = LONGLONG((double(i64Ticks100ns) * 10000000) / double(m_PerfFrequency) + 0.5);
return i64Ticks100ns;
}
diff --git a/src/apps/mplayerc/mplayerc.cz.rc b/src/apps/mplayerc/mplayerc.cz.rc Binary files differindex d631092dc..7c91a5336 100644 --- a/src/apps/mplayerc/mplayerc.cz.rc +++ b/src/apps/mplayerc/mplayerc.cz.rc diff --git a/src/apps/mplayerc/mplayerc.de.rc b/src/apps/mplayerc/mplayerc.de.rc Binary files differindex 94a4a33ab..50bf1aba1 100644 --- a/src/apps/mplayerc/mplayerc.de.rc +++ b/src/apps/mplayerc/mplayerc.de.rc diff --git a/src/apps/mplayerc/mplayerc.es.rc b/src/apps/mplayerc/mplayerc.es.rc Binary files differindex 3c21eecf9..463ce9765 100644 --- a/src/apps/mplayerc/mplayerc.es.rc +++ b/src/apps/mplayerc/mplayerc.es.rc diff --git a/src/apps/mplayerc/mplayerc.fr.rc b/src/apps/mplayerc/mplayerc.fr.rc Binary files differindex e3cf3db23..e15522dec 100644 --- a/src/apps/mplayerc/mplayerc.fr.rc +++ b/src/apps/mplayerc/mplayerc.fr.rc diff --git a/src/apps/mplayerc/mplayerc.h b/src/apps/mplayerc/mplayerc.h index dfeb7dbba..eb899549a 100644 --- a/src/apps/mplayerc/mplayerc.h +++ b/src/apps/mplayerc/mplayerc.h @@ -159,6 +159,7 @@ enum VIDRNDT_DS_NULL_UNCOMP,
VIDRNDT_DS_EVR,
VIDRNDT_DS_EVR_CUSTOM,
+ VIDRNDT_DS_MADVR
};
enum
@@ -393,7 +394,7 @@ public: // === CASIMIR666 : Ajout CMPlayerCApp
bool m_fTearingTest;
- bool m_fDisplayStats;
+ int m_fDisplayStats;
LONGLONG m_PerfFrequency;
CString m_strVersion;
CString m_strD3DX9Version;
@@ -471,11 +472,78 @@ public: CAutoPtrList<FilterOverride> filters;
+ class CRendererSettingsShared
+ {
+ public:
+ CRendererSettingsShared()
+ {
+ SetDefault();
+ }
+ bool fVMR9AlterativeVSync;
+ int iVMR9VSyncOffset;
+ bool iVMR9VSyncAccurate;
+ bool iVMR9FullscreenGUISupport;
+ bool iVMR9VSync;
+ bool iVMRDisableDesktopComposition;
+ int iVMRFlushGPUBeforeVSync;
+ int iVMRFlushGPUAfterPresent;
+ int iVMRFlushGPUWait;
+
+ void SetDefault()
+ {
+ fVMR9AlterativeVSync = 0;
+ iVMR9VSyncOffset = 0;
+ iVMR9VSyncAccurate = 1;
+ iVMR9FullscreenGUISupport = 0;
+ iVMR9VSync = 1;
+ iVMRDisableDesktopComposition = 0;
+ iVMRFlushGPUBeforeVSync = 1;
+ iVMRFlushGPUAfterPresent = 1;
+ iVMRFlushGPUWait = 0;
+ }
+ void SetOptimal()
+ {
+ fVMR9AlterativeVSync = 1;
+ iVMR9VSyncAccurate = 1;
+ iVMR9VSync = 1;
+ iVMRDisableDesktopComposition = 1;
+ iVMRFlushGPUBeforeVSync = 1;
+ iVMRFlushGPUAfterPresent = 1;
+ iVMRFlushGPUWait = 0;
+ }
+ };
+ class CRendererSettingsEVR : public CRendererSettingsShared
+ {
+ public:
+ bool iEVRHighColorResolution;
+ bool iEVREnableFrameTimeCorrection;
+ int iEVROutputRange;
+
+ CRendererSettingsEVR()
+ {
+ SetDefault();
+ }
+ void SetDefault()
+ {
+ CRendererSettingsShared::SetDefault();
+ iEVRHighColorResolution = 0;
+ iEVREnableFrameTimeCorrection = 0;
+ iEVROutputRange = 0;
+ }
+ void SetOptimal()
+ {
+ CRendererSettingsShared::SetOptimal();
+ iEVRHighColorResolution = 0;
+ }
+ };
+
+ CRendererSettingsEVR m_RenderSettings;
+
int iDSVideoRendererType;
int iRMVideoRendererType;
int iQTVideoRendererType;
int iAPSurfaceUsage;
- bool fVMRSyncFix;
+// bool fVMRSyncFix;
int iDX9Resizer;
bool fVMR9MixerMode;
bool fVMR9MixerYUV;
@@ -528,6 +596,7 @@ public: int nSPCMaxRes;
int nSubDelayInterval;
bool fSPCPow2Tex;
+ bool fSPCDisableAnim;
bool fEnableSubtitles;
bool fDisabeXPToolbars;
@@ -596,9 +665,15 @@ public: CString ISDb;
- struct Shader {CString label, target, srcdata;};
+ struct Shader
+ {
+ CString label;
+ CString target;
+ CString srcdata;
+ };
CAtlList<Shader> m_shaders;
CString m_shadercombine;
+ CString m_shadercombineScreenSpace;
// === CASIMIR666 : nouveau settings
bool fD3DFullscreen;
@@ -610,6 +685,7 @@ public: float dHue;
float dSaturation;
CString strShaderList;
+ CString strShaderListScreenSpace;
bool fRememberDVDPos;
bool fRememberFilePos;
diff --git a/src/apps/mplayerc/mplayerc.hu.rc b/src/apps/mplayerc/mplayerc.hu.rc Binary files differindex c39b41be6..bfad7e792 100644 --- a/src/apps/mplayerc/mplayerc.hu.rc +++ b/src/apps/mplayerc/mplayerc.hu.rc diff --git a/src/apps/mplayerc/mplayerc.it.rc b/src/apps/mplayerc/mplayerc.it.rc Binary files differindex 9356eaa3b..a12b7ad4d 100644 --- a/src/apps/mplayerc/mplayerc.it.rc +++ b/src/apps/mplayerc/mplayerc.it.rc diff --git a/src/apps/mplayerc/mplayerc.kr.rc b/src/apps/mplayerc/mplayerc.kr.rc Binary files differindex e3c5444e1..4f3a81b6d 100644 --- a/src/apps/mplayerc/mplayerc.kr.rc +++ b/src/apps/mplayerc/mplayerc.kr.rc diff --git a/src/apps/mplayerc/mplayerc.pl.rc b/src/apps/mplayerc/mplayerc.pl.rc Binary files differindex eae2c9595..6c6f67982 100644 --- a/src/apps/mplayerc/mplayerc.pl.rc +++ b/src/apps/mplayerc/mplayerc.pl.rc diff --git a/src/apps/mplayerc/mplayerc.rc b/src/apps/mplayerc/mplayerc.rc Binary files differindex 88cf3bdf5..a5e144b0d 100644 --- a/src/apps/mplayerc/mplayerc.rc +++ b/src/apps/mplayerc/mplayerc.rc diff --git a/src/apps/mplayerc/mplayerc.ru.rc b/src/apps/mplayerc/mplayerc.ru.rc Binary files differindex 7d6a5044c..91719b116 100644 --- a/src/apps/mplayerc/mplayerc.ru.rc +++ b/src/apps/mplayerc/mplayerc.ru.rc diff --git a/src/apps/mplayerc/mplayerc.sc.rc b/src/apps/mplayerc/mplayerc.sc.rc Binary files differindex 218398951..3718f3d5f 100644 --- a/src/apps/mplayerc/mplayerc.sc.rc +++ b/src/apps/mplayerc/mplayerc.sc.rc diff --git a/src/apps/mplayerc/mplayerc.sk.rc b/src/apps/mplayerc/mplayerc.sk.rc Binary files differindex 3101d3fd2..1c0e007cd 100644 --- a/src/apps/mplayerc/mplayerc.sk.rc +++ b/src/apps/mplayerc/mplayerc.sk.rc diff --git a/src/apps/mplayerc/mplayerc.tc.rc b/src/apps/mplayerc/mplayerc.tc.rc Binary files differindex f3f566f4d..541b16541 100644 --- a/src/apps/mplayerc/mplayerc.tc.rc +++ b/src/apps/mplayerc/mplayerc.tc.rc diff --git a/src/apps/mplayerc/mplayerc.tr.rc b/src/apps/mplayerc/mplayerc.tr.rc Binary files differindex bbf035267..e1f84ff14 100644 --- a/src/apps/mplayerc/mplayerc.tr.rc +++ b/src/apps/mplayerc/mplayerc.tr.rc diff --git a/src/apps/mplayerc/mplayerc.ua.rc b/src/apps/mplayerc/mplayerc.ua.rc Binary files differindex 4ce91bdaf..a8580b183 100644 --- a/src/apps/mplayerc/mplayerc.ua.rc +++ b/src/apps/mplayerc/mplayerc.ua.rc diff --git a/src/apps/mplayerc/mplayerc.vcproj b/src/apps/mplayerc/mplayerc.vcproj index 9df3e7a38..7dc94fdd5 100644 --- a/src/apps/mplayerc/mplayerc.vcproj +++ b/src/apps/mplayerc/mplayerc.vcproj @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="windows-1250"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="9,00"
+ Version="9.00"
Name="mplayerc"
ProjectGUID="{8CE7E5D0-C821-47AC-A247-28EC95B34670}"
RootNamespace="mplayerc"
@@ -27,6 +27,7 @@ UseOfATL="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
+ WholeProgramOptimization="0"
>
<Tool
Name="VCPreBuildEventTool"
@@ -50,8 +51,10 @@ />
<Tool
Name="VCCLCompilerTool"
+ AdditionalOptions="/MP"
AdditionalIncludeDirectories="..\..\..\include;..\..\zlib"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;DETOURS_X32"
+ UsePrecompiledHeader="2"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile="$(OutDir)\$(ProjectName).pch"
/>
@@ -76,6 +79,7 @@ IgnoreDefaultLibraryNames="MSVCRT"
DelayLoadDLLs="d3d9.dll;msimg32.dll;gdiplus.dll;psapi.dll"
SubSystem="2"
+ LargeAddressAware="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="1"
SupportUnloadOfDelayLoadedDLL="true"
@@ -137,8 +141,10 @@ />
<Tool
Name="VCCLCompilerTool"
+ AdditionalOptions="/MP"
AdditionalIncludeDirectories="..\..\..\include;..\..\zlib"
PreprocessorDefinitions="_WIN64;NDEBUG;_WINDOWS;DETOURS_X64"
+ UsePrecompiledHeader="2"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile="$(OutDir)\$(ProjectName).pch"
/>
@@ -222,8 +228,10 @@ />
<Tool
Name="VCCLCompilerTool"
+ AdditionalOptions="/MP"
AdditionalIncludeDirectories="..\..\..\include;..\..\zlib"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;DETOURS_X32"
+ UsePrecompiledHeader="2"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile="$(OutDir)\$(ProjectName).pch"
ShowIncludes="false"
@@ -306,8 +314,10 @@ />
<Tool
Name="VCCLCompilerTool"
+ AdditionalOptions="/MP"
AdditionalIncludeDirectories="..\..\..\include;..\..\zlib"
PreprocessorDefinitions="_WIN64;_DEBUG;_WINDOWS;DETOURS_X64"
+ UsePrecompiledHeader="2"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile="$(OutDir)\$(ProjectName).pch"
DebugInformationFormat="3"
@@ -417,6 +427,14 @@ <File
RelativePath="DX9AllocatorPresenter.cpp"
>
+ <FileConfiguration
+ Name="Release Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ WholeProgramOptimization="true"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath=".\EditListEditor.cpp"
@@ -425,6 +443,14 @@ <File
RelativePath=".\EVRAllocatorPresenter.cpp"
>
+ <FileConfiguration
+ Name="Release Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ WholeProgramOptimization="true"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath=".\FakeFilterMapper2.cpp"
@@ -473,6 +499,38 @@ <File
RelativePath="..\ShuttlePN31\Common\Interface.c"
>
+ <FileConfiguration
+ Name="Release Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath=".\IPinHook.cpp"
@@ -497,6 +555,42 @@ <File
RelativePath=".\libpng.c"
>
+ <FileConfiguration
+ Name="Release Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ WarningLevel="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ WarningLevel="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ WarningLevel="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ WarningLevel="1"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath=".\LineNumberEdit.cpp"
@@ -625,6 +719,42 @@ <File
RelativePath=".\pngdib.c"
>
+ <FileConfiguration
+ Name="Release Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ WarningLevel="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ WarningLevel="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ WarningLevel="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ WarningLevel="2"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath="PnSPresetsDlg.cpp"
@@ -853,6 +983,38 @@ <File
RelativePath=".\WebServer.cpp"
>
+ <FileConfiguration
+ Name="Release Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath=".\WebServerSocket.cpp"
@@ -1795,10 +1957,22 @@ </Filter>
</Filter>
<File
+ RelativePath=".\res\shaders\BT601BT709.psh"
+ >
+ </File>
+ <File
RelativePath=".\ChangeLog"
>
</File>
<File
+ RelativePath=".\res\shaders\levels2.psh"
+ >
+ </File>
+ <File
+ RelativePath=".\res\shaders\levels3.psh"
+ >
+ </File>
+ <File
RelativePath=".\res\PN31Snoop.sys"
>
</File>
diff --git a/src/apps/mplayerc/res/shaders/levels3.psh b/src/apps/mplayerc/res/shaders/levels3.psh new file mode 100644 index 000000000..5b7f16f28 --- /dev/null +++ b/src/apps/mplayerc/res/shaders/levels3.psh @@ -0,0 +1,24 @@ +sampler s0 : register(s0);
+
+#define const_1 (16.0/255.0)
+#define const_2 (219.0/255.0)
+
+float4 main(float2 tex : TEXCOORD0) : COLOR
+{
+ // original pixel
+ float4 c0 = tex2D(s0,tex);
+
+ return (c0 * const_2) + const_1;
+}
+sampler s0 : register(s0);
+
+#define const_1 (16.0/255.0)
+#define const_2 (219.0/255.0)
+
+float4 main(float2 tex : TEXCOORD0) : COLOR
+{
+ // original pixel
+ float4 c0 = tex2D(s0,tex);
+
+ return (c0 * const_2) + const_1;
+}
diff --git a/src/apps/mplayerc/resource.h b/src/apps/mplayerc/resource.h Binary files differindex 9ff018b88..7c5e3dc9c 100644 --- a/src/apps/mplayerc/resource.h +++ b/src/apps/mplayerc/resource.h |