diff options
author | kasper93 <kasper93@gmail.com> | 2014-04-12 21:46:23 +0400 |
---|---|---|
committer | kasper93 <kasper93@gmail.com> | 2014-05-03 00:41:14 +0400 |
commit | de0c6509bbbf9a0fc1f350af31408392ddc997f2 (patch) | |
tree | b9814d59a4f60639f726ca187535443598285045 /src/filters/transform/VSFilter | |
parent | 5947b7738531e5c841dafc89635ab7f0b24f80f9 (diff) |
VSFilter/ISR: Fix override placement not being applied even if enabled.
ISR: Fix subtitle default style being lost after changing default style in settings.
Fixes #34.
Diffstat (limited to 'src/filters/transform/VSFilter')
-rw-r--r-- | src/filters/transform/VSFilter/DirectVobSubFilter.cpp | 82 | ||||
-rw-r--r-- | src/filters/transform/VSFilter/DirectVobSubFilter.h | 6 |
2 files changed, 31 insertions, 57 deletions
diff --git a/src/filters/transform/VSFilter/DirectVobSubFilter.cpp b/src/filters/transform/VSFilter/DirectVobSubFilter.cpp index a03e9935b..60fd909e0 100644 --- a/src/filters/transform/VSFilter/DirectVobSubFilter.cpp +++ b/src/filters/transform/VSFilter/DirectVobSubFilter.cpp @@ -566,7 +566,7 @@ void CDirectVobSubFilter::InitSubPicQueue() m_pSubPicQueue = nullptr;
}
- UpdateSubtitle(false);
+ UpdateSubtitle();
if (m_hbm) {
DeleteObject(m_hbm);
@@ -970,7 +970,7 @@ STDMETHODIMP CDirectVobSubFilter::put_SelectedLanguage(int iSelected) HRESULT hr = CDirectVobSub::put_SelectedLanguage(iSelected);
if (hr == NOERROR) {
- UpdateSubtitle(false);
+ UpdateSubtitle();
}
return hr;
@@ -981,7 +981,7 @@ STDMETHODIMP CDirectVobSubFilter::put_HideSubtitles(bool fHideSubtitles) HRESULT hr = CDirectVobSub::put_HideSubtitles(fHideSubtitles);
if (hr == NOERROR) {
- UpdateSubtitle(false);
+ UpdateSubtitle();
}
return hr;
@@ -1026,7 +1026,7 @@ STDMETHODIMP CDirectVobSubFilter::put_Placement(bool fOverridePlacement, int xpe HRESULT hr = CDirectVobSub::put_Placement(fOverridePlacement, xperc, yperc);
if (hr == NOERROR) {
- UpdateSubtitle(true);
+ UpdateSubtitle();
}
return hr;
@@ -1037,7 +1037,6 @@ STDMETHODIMP CDirectVobSubFilter::put_VobSubSettings(bool fBuffer, bool fOnlySho HRESULT hr = CDirectVobSub::put_VobSubSettings(fBuffer, fOnlyShowForcedSubs, fReserved);
if (hr == NOERROR) {
- // UpdateSubtitle(false);
InvalidateSubtitle();
}
@@ -1049,7 +1048,6 @@ STDMETHODIMP CDirectVobSubFilter::put_TextSettings(void* lf, int lflen, COLORREF HRESULT hr = CDirectVobSub::put_TextSettings(lf, lflen, color, fShadow, fOutline, fAdvancedRenderer);
if (hr == NOERROR) {
- // UpdateSubtitle(true);
InvalidateSubtitle();
}
@@ -1119,7 +1117,7 @@ STDMETHODIMP CDirectVobSubFilter::put_TextSettings(STSStyle* pDefStyle) HRESULT hr = CDirectVobSub::put_TextSettings(pDefStyle);
if (hr == NOERROR) {
- UpdateSubtitle(true);
+ UpdateSubtitle();
}
return hr;
@@ -1130,7 +1128,7 @@ STDMETHODIMP CDirectVobSubFilter::put_AspectRatioSettings(CSimpleTextSubtitle::E HRESULT hr = CDirectVobSub::put_AspectRatioSettings(ePARCompensationType);
if (hr == NOERROR) {
- UpdateSubtitle(true);
+ UpdateSubtitle();
}
return hr;
@@ -1498,7 +1496,7 @@ bool CDirectVobSubFilter::Open() }
if (S_FALSE == put_SelectedLanguage(FindPreferedLanguage())) {
- UpdateSubtitle(false); // make sure pSubPicProvider of our queue gets updated even if the stream number hasn't changed
+ UpdateSubtitle(); // make sure pSubPicProvider of our queue gets updated even if the stream number hasn't changed
}
m_frd.RefreshEvent.Set();
@@ -1506,7 +1504,7 @@ bool CDirectVobSubFilter::Open() return !m_pSubStreams.IsEmpty();
}
-void CDirectVobSubFilter::UpdateSubtitle(bool fApplyDefStyle)
+void CDirectVobSubFilter::UpdateSubtitle()
{
CAutoLock cAutolock(&m_csQueueLock);
@@ -1534,10 +1532,10 @@ void CDirectVobSubFilter::UpdateSubtitle(bool fApplyDefStyle) }
}
- SetSubtitle(pSubStream, fApplyDefStyle);
+ SetSubtitle(pSubStream);
}
-void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyle)
+void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream)
{
CAutoLock cAutolock(&m_csQueueLock);
@@ -1547,51 +1545,30 @@ void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyl CLSID clsid;
pSubStream->GetClassID(&clsid);
- if (clsid == __uuidof(CVobSubFile)) {
- CVobSubSettings* pVSS = (CVobSubFile*)(ISubStream*)pSubStream;
-
- if (fApplyDefStyle) {
- pVSS->SetAlignment(m_fOverridePlacement, m_PlacementXperc, m_PlacementYperc, 1, 1);
- pVSS->m_fOnlyShowForcedSubs = m_fOnlyShowForcedVobSubs;
- }
- } else if (clsid == __uuidof(CVobSubStream)) {
- CVobSubSettings* pVSS = (CVobSubStream*)(ISubStream*)pSubStream;
-
- if (fApplyDefStyle) {
- pVSS->SetAlignment(m_fOverridePlacement, m_PlacementXperc, m_PlacementYperc, 1, 1);
+ if (clsid == __uuidof(CVobSubFile) || clsid == __uuidof(CVobSubStream)) {
+ if (auto pVSS = dynamic_cast<CVobSubSettings*>(pSubStream)) {
+ pVSS->SetAlignment(m_fOverridePlacement, m_PlacementXperc, m_PlacementYperc);
pVSS->m_fOnlyShowForcedSubs = m_fOnlyShowForcedVobSubs;
}
} else if (clsid == __uuidof(CRenderedTextSubtitle)) {
- CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)pSubStream;
-
- if (fApplyDefStyle || pRTS->m_fUsingAutoGeneratedDefaultStyle) {
- STSStyle s = m_defStyle;
-
- if (m_fOverridePlacement) {
- s.scrAlignment = 2;
- int w = pRTS->m_dstScreenSize.cx;
- int h = pRTS->m_dstScreenSize.cy;
- int mw = w - s.marginRect.left - s.marginRect.right;
- s.marginRect.bottom = h - MulDiv(h, m_PlacementYperc, 100);
- s.marginRect.left = MulDiv(w, m_PlacementXperc, 100) - mw / 2;
- s.marginRect.right = w - (s.marginRect.left + mw);
- }
+ CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)pSubStream;
- pRTS->SetDefaultStyle(s);
+ if (pRTS->m_fUsingAutoGeneratedDefaultStyle) {
+ pRTS->SetDefaultStyle(m_defStyle);
}
pRTS->m_ePARCompensationType = m_ePARCompensationType;
- if (m_CurrentVIH2.dwPictAspectRatioX != 0 && m_CurrentVIH2.dwPictAspectRatioY != 0 && m_CurrentVIH2.bmiHeader.biWidth != 0 && m_CurrentVIH2.bmiHeader.biHeight != 0) {
+ if (m_CurrentVIH2.dwPictAspectRatioX && m_CurrentVIH2.dwPictAspectRatioY && m_CurrentVIH2.bmiHeader.biWidth && m_CurrentVIH2.bmiHeader.biHeight) {
pRTS->m_dPARCompensation = ((double)abs(m_CurrentVIH2.bmiHeader.biWidth) / (double)abs(m_CurrentVIH2.bmiHeader.biHeight)) /
((double)abs((long)m_CurrentVIH2.dwPictAspectRatioX) / (double)abs((long)m_CurrentVIH2.dwPictAspectRatioY));
-
} else {
pRTS->m_dPARCompensation = 1.00;
}
+ pRTS->SetAlignment(m_fOverridePlacement, m_PlacementXperc, m_PlacementYperc);
pRTS->Deinit();
} else if (clsid == __uuidof(CRLECodedSubtitle)) {
- CRLECodedSubtitle* pRHS = (CRLECodedSubtitle*)(ISubStream*)pSubStream;
+ CRLECodedSubtitle* pRHS = (CRLECodedSubtitle*)pSubStream;
DXVA2_ExtendedFormat extFormat;
extFormat.value = m_cf;
@@ -1617,20 +1594,17 @@ void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyl }
}
- if (!fApplyDefStyle) {
- int i = 0;
-
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while (pos) {
- CComPtr<ISubStream> pSubStream2 = m_pSubStreams.GetNext(pos);
-
- if (pSubStream == pSubStream2) {
- m_iSelectedLanguage = i + pSubStream2->GetStream();
- break;
- }
+ int i = 0;
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while (pos) {
+ CComPtr<ISubStream> pSubStream2 = m_pSubStreams.GetNext(pos);
- i += pSubStream2->GetStreamCount();
+ if (pSubStream == pSubStream2) {
+ m_iSelectedLanguage = i + pSubStream2->GetStream();
+ break;
}
+
+ i += pSubStream2->GetStreamCount();
}
m_nSubtitleId = (DWORD_PTR)pSubStream;
diff --git a/src/filters/transform/VSFilter/DirectVobSubFilter.h b/src/filters/transform/VSFilter/DirectVobSubFilter.h index 39d7baf2a..fd2e924ec 100644 --- a/src/filters/transform/VSFilter/DirectVobSubFilter.h +++ b/src/filters/transform/VSFilter/DirectVobSubFilter.h @@ -1,6 +1,6 @@ /*
* (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
+ * (C) 2006-2014 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -150,8 +150,8 @@ protected: CCritSec m_csSubLock;
CInterfaceList<ISubStream> m_pSubStreams;
DWORD_PTR m_nSubtitleId;
- void UpdateSubtitle(bool fApplyDefStyle = true);
- void SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyle = true);
+ void UpdateSubtitle();
+ void SetSubtitle(ISubStream* pSubStream);
void InvalidateSubtitle(REFERENCE_TIME rtInvalidate = -1, DWORD_PTR nSubtitleId = DWORD_PTR_MAX);
// the text input pin is using these
|