Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Add position and duration (in seconds) access to shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
on-situ-repos committed Mar 4, 2016
1 parent 9d4af7d commit 3583d3b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/SubPic/ISubPic.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ public IUnknown {
STDMETHOD_(bool, Paint)(bool bAll) PURE;

STDMETHOD_(void, SetTime)(REFERENCE_TIME rtNow) PURE;
STDMETHOD_(void, SetSubtitleDelay)(int delayMs) PURE;
STDMETHOD_(void, SetDuration)(REFERENCE_TIME rtDuration) PURE;
STDMETHOD_(void, SetSubtitleDelay)(int delayMs) PURE;
STDMETHOD_(int, GetSubtitleDelay)() const PURE;
STDMETHOD_(double, GetFPS)() const PURE;

Expand Down
6 changes: 6 additions & 0 deletions src/SubPic/SubPicAllocatorPresenterImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ CSubPicAllocatorPresenterImpl::CSubPicAllocatorPresenterImpl(HWND hWnd, HRESULT&
, m_bDeviceResetRequested(false)
, m_bPendingResetDevice(false)
, m_SubtitleTextureLimit(STATIC)
, m_rtDuration(0)
{
if (!IsWindow(m_hWnd)) {
hr = E_INVALIDARG;
Expand Down Expand Up @@ -203,6 +204,11 @@ STDMETHODIMP_(void) CSubPicAllocatorPresenterImpl::SetTime(REFERENCE_TIME rtNow)
}
}

STDMETHODIMP_(void) CSubPicAllocatorPresenterImpl::SetDuration(REFERENCE_TIME rtDuration)
{
m_rtDuration = rtDuration;
}

STDMETHODIMP_(void) CSubPicAllocatorPresenterImpl::SetSubtitleDelay(int delayMs)
{
m_rtSubtitleDelay = delayMs * 10000i64;
Expand Down
2 changes: 2 additions & 0 deletions src/SubPic/SubPicAllocatorPresenterImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class CSubPicAllocatorPresenterImpl
CRect m_videoRect, m_windowRect;

REFERENCE_TIME m_rtNow;
REFERENCE_TIME m_rtDuration;
double m_fps;
UINT m_refreshRate;

Expand Down Expand Up @@ -92,6 +93,7 @@ class CSubPicAllocatorPresenterImpl
STDMETHODIMP_(bool) Paint(bool bAll) PURE;

STDMETHODIMP_(void) SetTime(REFERENCE_TIME rtNow);
STDMETHODIMP_(void) SetDuration(REFERENCE_TIME rtDuration);
STDMETHODIMP_(void) SetSubtitleDelay(int delayMs);
STDMETHODIMP_(int) GetSubtitleDelay() const;
STDMETHODIMP_(double) GetFPS() const;
Expand Down
14 changes: 11 additions & 3 deletions src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,20 +390,24 @@ HRESULT CDX9RenderingEngine::RenderVideoDrawPath(IDirect3DSurface9* pRenderTarge
start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
}

const float fOneSecond = 10000000.0f;
float fPosition = m_rtNow / fOneSecond;
float fDuration = m_rtDuration / fOneSecond;

#if 1
D3DSURFACE_DESC desc;
m_pVideoTexture[m_nCurSurface]->GetLevelDesc(0, &desc);

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},
{1.0f / desc.Width, 1.0f / desc.Height, fPosition, fDuration},
};
#else
CSize VideoSize = GetVisibleVideoSize();
float fConstData[][4] = {
{(float)VideoSize.cx, (float)VideoSize.cy, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
{1.0f / VideoSize.cx, 1.0f / VideoSize.cy, 0, 0},
{1.0f / VideoSize.cx, 1.0f / VideoSize.cy, fPosition, fDuration},
};
#endif

Expand Down Expand Up @@ -477,9 +481,13 @@ HRESULT CDX9RenderingEngine::RenderVideoDrawPath(IDirect3DSurface9* pRenderTarge
start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
}

const float fOneSecond = 10000000.0f;
float fPosition = m_rtNow / fOneSecond;
float fDuration = m_rtDuration / fOneSecond;

float fConstData[][4] = {
{(float)m_TemporaryScreenSpaceTextureSize.cx, (float)m_TemporaryScreenSpaceTextureSize.cy, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
{1.0f / m_TemporaryScreenSpaceTextureSize.cx, 1.0f / m_TemporaryScreenSpaceTextureSize.cy, 0, 0},
{1.0f / m_TemporaryScreenSpaceTextureSize.cx, 1.0f / m_TemporaryScreenSpaceTextureSize.cy, fPosition, fDuration},
};

hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
Expand Down
13 changes: 13 additions & 0 deletions src/mpc-hc/FGManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,19 @@ HRESULT CFGManager::Connect(IPin* pPinOut, IPin* pPinIn, bool bContinueRender)
if (SUCCEEDED(hr)) {
m_pUnks.AddTailList(&pUnks);

CComQIPtr<IMediaSeeking> pMS = pPinOut;
if (pMS) {
REFERENCE_TIME rtDuration = 0;
if (SUCCEEDED(pMS->GetDuration(&rtDuration))) {
POSITION posInterface = pUnks.GetHeadPosition();
while (posInterface) {
if (CComQIPtr<ISubPicAllocatorPresenter2> pCAP = pUnks.GetNext(posInterface)) {
pCAP->SetDuration(rtDuration);
}
}
}
}

// maybe the application should do this...

POSITION posInterface = pUnks.GetHeadPosition();
Expand Down

0 comments on commit 3583d3b

Please sign in to comment.