diff options
author | Aleksoid <aleksoid@users.sourceforge.net> | 2011-06-13 02:15:30 +0400 |
---|---|---|
committer | Aleksoid <aleksoid@users.sourceforge.net> | 2011-06-13 02:15:30 +0400 |
commit | 213c5c0539c8136cedd1ef80289e1325e03ed044 (patch) | |
tree | 95ed927602e12a72f93c1ed46fe53efe8a0f9e52 /src/filters/parser/MpegSplitter | |
parent | 567ae2c3612d5636f952afbe009dee9021e90f83 (diff) |
Add : MPEGSplitter, "Forced load all subtitles" as option. If enable - all subtitle load at opening of file, but can insert "fake" subtitle without real data.
Small code rewrite;
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@3217 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/parser/MpegSplitter')
7 files changed, 63 insertions, 22 deletions
diff --git a/src/filters/parser/MpegSplitter/IMpegSplitterFilter.h b/src/filters/parser/MpegSplitter/IMpegSplitterFilter.h index 1b9983657..d80ab170c 100644 --- a/src/filters/parser/MpegSplitter/IMpegSplitterFilter.h +++ b/src/filters/parser/MpegSplitter/IMpegSplitterFilter.h @@ -30,6 +30,9 @@ public IUnknown { STDMETHOD(SetFastStreamChange(BOOL nValue)) = 0;
STDMETHOD_(BOOL, GetFastStreamChange()) = 0;
+ STDMETHOD(SetForcedSub(BOOL nValue)) = 0;
+ STDMETHOD_(BOOL, GetForcedSub()) = 0;
+
STDMETHOD(SetAudioLanguageOrder(WCHAR *nValue)) = 0;
STDMETHOD_(WCHAR *, GetAudioLanguageOrder()) = 0;
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.cpp b/src/filters/parser/MpegSplitter/MpegSplitter.cpp index 328eb02e0..f7ba719fa 100644 --- a/src/filters/parser/MpegSplitter/MpegSplitter.cpp +++ b/src/filters/parser/MpegSplitter/MpegSplitter.cpp @@ -65,7 +65,6 @@ TCHAR* MPEG2_Level[]= const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1System},
- // {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1VideoCD}, // cdxa filter should take care of this
{&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG2_PROGRAM},
{&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG2_TRANSPORT},
{&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG2_PVA},
@@ -109,9 +108,6 @@ STDAPI DllRegisterServer() STDAPI DllUnregisterServer()
{
- // UnRegisterSourceFilter(MEDIASUBTYPE_MPEG1System);
- // UnRegisterSourceFilter(MEDIASUBTYPE_MPEG2_PROGRAM);
-
return AMovieDllRegisterServer2(FALSE);
}
@@ -499,6 +495,7 @@ CMpegSplitterFilter::CMpegSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLS , m_csAudioLanguageOrder(_T(""))
, m_csSubtitlesLanguageOrder(_T(""))
, m_useFastStreamChange(true)
+ , m_ForcedSub(false)
, m_nVC1_GuidFlag(1)
{
#ifdef REGISTER_FILTER
@@ -513,6 +510,10 @@ CMpegSplitterFilter::CMpegSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLS m_useFastStreamChange = dw;
}
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ForcedSub"), dw)) {
+ m_ForcedSub = dw;
+ }
+
len = sizeof(buff)/sizeof(buff[0]);
memset(buff, 0, sizeof(buff));
if(ERROR_SUCCESS == key.QueryStringValue(_T("AudioLanguageOrder"), buff, &len)) {
@@ -531,6 +532,7 @@ CMpegSplitterFilter::CMpegSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLS }
#else
m_useFastStreamChange = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("UseFastStreamChange"), m_useFastStreamChange);
+ m_ForcedSub = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("ForcedSub"), m_ForcedSub);
m_csSubtitlesLanguageOrder = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANGORDER, _T(""));
m_csAudioLanguageOrder = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, IDS_RS_AUDIOSLANGORDER, _T(""));
m_nVC1_GuidFlag = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("VC1_Decoder_Output"), m_nVC1_GuidFlag);
@@ -670,9 +672,9 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset) __int64 pos = m_pFile->GetPos();
- m_pFile->UpdatePrograms(h);
+ m_pFile->UpdatePrograms(h, false);
- if(h.payload && ISVALIDPID(h.pid)/* && !h.scrambling*/) {
+ if(h.payload && ISVALIDPID(h.pid)) {
DWORD TrackNumber = h.pid;
CMpegSplitterFile::peshdr h2;
@@ -695,7 +697,7 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset) if (h.fPCR) {
CRefTime rtNow;
StreamTime(rtNow);
- TRACE ("Now=%S PCR=%S\n", ReftimeToString(rtNow.m_time), ReftimeToString(h.PCR));
+ //TRACE ("Now=%S PCR=%S\n", ReftimeToString(rtNow.m_time), ReftimeToString(h.PCR));
}
p->rtStart = h2.fpts ? (h2.pts - rtStartOffset) : Packet::INVALID_TIME;
@@ -751,7 +753,7 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_pFile.Free();
ReadClipInfo (GetPartFilename(pAsyncReader));
- m_pFile.Attach(DNew CMpegSplitterFile(pAsyncReader, hr, m_ClipInfo.IsHdmv(), m_ClipInfo, m_nVC1_GuidFlag));
+ m_pFile.Attach(DNew CMpegSplitterFile(pAsyncReader, hr, m_ClipInfo.IsHdmv(), m_ClipInfo, m_nVC1_GuidFlag, m_ForcedSub));
if(!m_pFile) {
return E_OUTOFMEMORY;
@@ -1412,12 +1414,14 @@ STDMETHODIMP CMpegSplitterFilter::Apply() CRegKey key;
if(ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Splitter"))) {
key.SetDWORDValue(_T("UseFastStreamChange"), m_useFastStreamChange);
+ key.SetDWORDValue(_T("ForcedSub"), m_ForcedSub);
key.SetStringValue(_T("AudioLanguageOrder"), m_csAudioLanguageOrder);
key.SetStringValue(_T("SubtitlesLanguageOrder"), m_csSubtitlesLanguageOrder);
key.SetDWORDValue(_T("VC1_Decoder_Output"), m_nVC1_GuidFlag);
}
#else
AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("UseFastStreamChange"), m_useFastStreamChange);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("ForcedSub"), m_ForcedSub);
AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("VC1_Decoder_Output"), m_nVC1_GuidFlag);
#endif
@@ -1436,6 +1440,19 @@ STDMETHODIMP_(BOOL) CMpegSplitterFilter::GetFastStreamChange() return m_useFastStreamChange;
}
+STDMETHODIMP CMpegSplitterFilter::SetForcedSub(BOOL nValue)
+{
+ CAutoLock cAutoLock(&m_csProps);
+ m_ForcedSub = nValue;
+ return S_OK;
+}
+
+STDMETHODIMP_(BOOL) CMpegSplitterFilter::GetForcedSub()
+{
+ CAutoLock cAutoLock(&m_csProps);
+ return m_ForcedSub;
+}
+
STDMETHODIMP CMpegSplitterFilter::SetAudioLanguageOrder(WCHAR *nValue)
{
CAutoLock cAutoLock(&m_csProps);
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.h b/src/filters/parser/MpegSplitter/MpegSplitter.h index 8343e1712..1935bce2b 100644 --- a/src/filters/parser/MpegSplitter/MpegSplitter.h +++ b/src/filters/parser/MpegSplitter/MpegSplitter.h @@ -72,7 +72,7 @@ protected: private:
CString m_csAudioLanguageOrder, m_csSubtitlesLanguageOrder;
- bool m_useFastStreamChange;
+ bool m_useFastStreamChange, m_ForcedSub;
int m_nVC1_GuidFlag;
CCritSec m_csProps;
@@ -104,6 +104,9 @@ public: STDMETHODIMP SetFastStreamChange(BOOL nValue);
STDMETHODIMP_(BOOL) GetFastStreamChange();
+ STDMETHODIMP SetForcedSub(BOOL nValue);
+ STDMETHODIMP_(BOOL) GetForcedSub();
+
STDMETHODIMP SetAudioLanguageOrder(WCHAR *nValue);
STDMETHODIMP_(WCHAR *) GetAudioLanguageOrder();
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp b/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp index 38d2dae1a..d2454ec21 100644 --- a/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp +++ b/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp @@ -28,7 +28,7 @@ #define MEGABYTE 1024*1024
-CMpegSplitterFile::CMpegSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, bool bIsHdmv, CHdmvClipInfo &ClipInfo, int guid_flag)
+CMpegSplitterFile::CMpegSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, bool bIsHdmv, CHdmvClipInfo &ClipInfo, int guid_flag, bool ForcedSub)
: CBaseSplitterFileEx(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false, true)
, m_type(us)
, m_rate(0)
@@ -36,9 +36,8 @@ CMpegSplitterFile::CMpegSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, bo , m_posMin(0), m_posMax(0)
, m_bIsHdmv(bIsHdmv)
, m_ClipInfo(ClipInfo)
- , PMT_find(false)
, m_nVC1_GuidFlag(guid_flag)
-
+ , m_ForcedSub(ForcedSub)
{
if(SUCCEEDED(hr)) {
hr = Init(pAsyncReader);
@@ -714,7 +713,7 @@ CAtlList<CMpegSplitterFile::stream>* CMpegSplitterFile::GetMasterStream() NULL;
}
-void CMpegSplitterFile::UpdatePrograms(const trhdr& h)
+void CMpegSplitterFile::UpdatePrograms(const trhdr& h, bool UpdateLang)
{
CAutoLock cAutoLock(&m_csProps);
@@ -766,7 +765,7 @@ void CMpegSplitterFile::UpdatePrograms(const trhdr& h) memcpy(pPair->m_value.ts_buffer, buffer, max_len);
} else {
CGolombBuffer gb(buffer, len);
- UpdatePrograms(gb, h.pid);
+ UpdatePrograms(gb, h.pid, UpdateLang);
}
}
} else {
@@ -778,14 +777,14 @@ void CMpegSplitterFile::UpdatePrograms(const trhdr& h) } else {
ByteRead(pPair->m_value.ts_buffer + pPair->m_value.ts_len_cur, pPair->m_value.ts_len_packet - pPair->m_value.ts_len_cur);
CGolombBuffer gb(pPair->m_value.ts_buffer, pPair->m_value.ts_len_packet);
- UpdatePrograms(gb, h.pid);
+ UpdatePrograms(gb, h.pid, UpdateLang);
}
}
}
}
}
-void CMpegSplitterFile::UpdatePrograms(CGolombBuffer gb, WORD pid)
+void CMpegSplitterFile::UpdatePrograms(CGolombBuffer gb, WORD pid, bool UpdateLang)
{
if(CAtlMap<WORD, program>::CPair* pPair = m_programs.Lookup(pid))
{
@@ -821,13 +820,26 @@ void CMpegSplitterFile::UpdatePrograms(CGolombBuffer gb, WORD pid) pPair->m_value.streams[i].pid = pid;
pPair->m_value.streams[i].type = (PES_STREAM_TYPE)stream_type;
+ if(m_ForcedSub) {
+ if(stream_type == PRESENTATION_GRAPHICS_STREAM) {
+ stream s;
+ s.pid = pid;
+ CMpegSplitterFile::hdmvsubhdr hdr;
+ if(Read(hdr, &s.mt, NULL)) {
+ if(!m_streams[subpic].Find(s)) {
+ m_streams[subpic].Insert(s, this);
+ }
+ }
+ }
+ }
+
len -= (5 + ES_info_length);
if(len < 0)
break;
if(ES_info_length<=2)
continue;
- if(!PMT_find) {
+ if(UpdateLang) {
int info_length = ES_info_length;
for(;;) {
BYTE descriptor_tag = gb.BitRead(8);
@@ -865,7 +877,6 @@ void CMpegSplitterFile::UpdatePrograms(CGolombBuffer gb, WORD pid) }
}
}
- PMT_find = true;
pPair->m_value.ts_len_cur = 0;
pPair->m_value.ts_len_packet = 0;
}
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterFile.h b/src/filters/parser/MpegSplitter/MpegSplitterFile.h index 7c5e23471..4114b90b5 100644 --- a/src/filters/parser/MpegSplitter/MpegSplitterFile.h +++ b/src/filters/parser/MpegSplitter/MpegSplitterFile.h @@ -45,7 +45,7 @@ class CMpegSplitterFile : public CBaseSplitterFileEx public:
CHdmvClipInfo &m_ClipInfo;
- CMpegSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, bool bIsHdmv, CHdmvClipInfo &ClipInfo, int guid_flag);
+ CMpegSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, bool bIsHdmv, CHdmvClipInfo &ClipInfo, int guid_flag, bool ForcedSub);
REFERENCE_TIME NextPTS(DWORD TrackNum);
@@ -58,6 +58,7 @@ public: int m_rate; // byte/sec
int m_nVC1_GuidFlag;
+ bool m_ForcedSub;
struct stream {
CMpegSplitterFile *m_pFile;
@@ -148,10 +149,9 @@ public: CAtlMap<WORD, program> m_programs;
- void UpdatePrograms(const trhdr& h);
- void UpdatePrograms(CGolombBuffer gb, WORD pid);
+ void UpdatePrograms(const trhdr& h, bool UpdateLang = true);
+ void UpdatePrograms(CGolombBuffer gb, WORD pid, bool UpdateLang = true);
const program* FindProgram(WORD pid, int &iStream, const CHdmvClipInfo::Stream * &_pClipInfo);
CAtlMap<DWORD, CString> m_pPMT_Lang;
- bool PMT_find;
};
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp b/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp index 2a530ab22..2ad6e91b9 100644 --- a/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp +++ b/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp @@ -66,6 +66,9 @@ bool CMpegSplitterSettingsWnd::OnActivate() nPosY += VERTICAL_SPACING;
m_cbFastStreamChange.Create (ResStr(IDS_MPEGSPLITTER_FSTREAM_CHANGE), WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_AUTOCHECKBOX|BS_LEFTTEXT, CRect (LEFT_SPACING, nPosY, 305, nPosY+15), this, IDC_PP_FAST_STREAM_SELECT);
+
+ nPosY += VERTICAL_SPACING;
+ m_cbForcedSub.Create (_T("Forced load all subtitles"), WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_AUTOCHECKBOX|BS_LEFTTEXT, CRect (LEFT_SPACING, nPosY, 305, nPosY+15), this, IDC_PP_SUBTITLE_FORCED);
nPosY += VERTICAL_SPACING;
m_txtAudioLanguageOrder.Create (ResStr(IDS_MPEGSPLITTER_LANG_ORDER), WS_VISIBLE|WS_CHILD, CRect (LEFT_SPACING, nPosY, 200, nPosY+15), this, (UINT)IDC_STATIC);
@@ -89,6 +92,7 @@ bool CMpegSplitterSettingsWnd::OnActivate() if(m_pMSF) {
m_cbFastStreamChange.SetCheck(m_pMSF->GetFastStreamChange());
+ m_cbForcedSub.SetCheck(m_pMSF->GetForcedSub());
m_edtAudioLanguageOrder.SetWindowText(m_pMSF->GetAudioLanguageOrder());
m_edtSubtitlesLanguageOrder.SetWindowText(m_pMSF->GetSubtitlesLanguageOrder());
m_cbVC1_GuidFlag.SetCurSel(m_pMSF->GetVC1_GuidFlag() - 1);
@@ -116,6 +120,7 @@ bool CMpegSplitterSettingsWnd::OnApply() if(m_pMSF) {
m_pMSF->SetFastStreamChange(m_cbFastStreamChange.GetCheck());
+ m_pMSF->SetForcedSub(m_cbForcedSub.GetCheck());
m_pMSF->SetVC1_GuidFlag(m_cbVC1_GuidFlag.GetCurSel() + 1);
#ifdef REGISTER_FILTER
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.h b/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.h index 1ab18230e..18e0c935e 100644 --- a/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.h +++ b/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.h @@ -32,6 +32,7 @@ private : CButton m_grpDefault;
CButton m_cbFastStreamChange;
+ CButton m_cbForcedSub;
CStatic m_txtAudioLanguageOrder;
CEdit m_edtAudioLanguageOrder;
CStatic m_txtSubtitlesLanguageOrder;
@@ -41,6 +42,7 @@ private : enum {
IDC_PP_FAST_STREAM_SELECT = 10000,
+ IDC_PP_SUBTITLE_FORCED,
IDC_PP_AUDIO_LANGUAGE_ORDER,
IDC_PP_SUBTITLES_LANGUAGE_ORDER,
IDC_PP_VC1_GUIDFLAG
|