Index: mpc-hc_subs.sln
===================================================================
--- mpc-hc_subs.sln	(revision 26069)
+++ mpc-hc_subs.sln	(working copy)
@@ -167,7 +167,7 @@
 		{C2082189-3ECB-4079-91FA-89D3C8A305C0}.Debug|Win32.Build.0 = Debug|Win32
 		{C2082189-3ECB-4079-91FA-89D3C8A305C0}.Debug|x64.ActiveCfg = Debug|x64
 		{C2082189-3ECB-4079-91FA-89D3C8A305C0}.Debug|x64.Build.0 = Debug|x64
-		{C2082189-3ECB-4079-91FA-89D3C8A305C0}.Release Unicode lib|Win32.ActiveCfg = Release|x64
+		{C2082189-3ECB-4079-91FA-89D3C8A305C0}.Release Unicode lib|Win32.ActiveCfg = Release|Win32
 		{C2082189-3ECB-4079-91FA-89D3C8A305C0}.Release Unicode lib|x64.ActiveCfg = Release|x64
 		{C2082189-3ECB-4079-91FA-89D3C8A305C0}.Release Unicode lib|x64.Build.0 = Release|x64
 		{C2082189-3ECB-4079-91FA-89D3C8A305C0}.Release Unicode|Win32.ActiveCfg = Release|x64
Index: mpc-hc_subs/src/subtitles/HdmvSub.cpp
===================================================================
--- mpc-hc_subs/src/subtitles/HdmvSub.cpp	(revision 26069)
+++ mpc-hc_subs/src/subtitles/HdmvSub.cpp	(working copy)
@@ -1,5 +1,5 @@
 /* 
- * $Id: HdmvSub.cpp 1982 2010-05-29 04:04:26Z kinddragon $
+ * $Id: HdmvSub.cpp 2063 2010-06-20 11:10:55Z casimir666 $
  *
  * (C) 2006-2010 see AUTHORS
  *
@@ -108,78 +108,89 @@
 	if (pData)
 	{
 		CGolombBuffer		SampleBuffer (pData, lSampleLen);
-		if (m_nCurSegment == NO_SEGMENT)
-		{
-			HDMV_SEGMENT_TYPE	nSegType	= (HDMV_SEGMENT_TYPE)SampleBuffer.ReadByte();
-			USHORT				nUnitSize	= SampleBuffer.ReadShort();
-			lSampleLen -=3;
 
-			switch (nSegType)
-			{
-			case PALETTE :
-			case OBJECT :
-			case PRESENTATION_SEG :
-			case END_OF_DISPLAY :
-				m_nCurSegment = nSegType;
-				AllocSegment (nUnitSize);
-				break;
-			default :
-				return VFW_E_SAMPLE_REJECTED;
-			}
-		}
-
-		if (m_nCurSegment != NO_SEGMENT)
+		while (!SampleBuffer.IsEOF())
 		{
-			if (m_nSegBufferPos < m_nSegSize)
+			if (m_nCurSegment == NO_SEGMENT)
 			{
-				int		nSize = min (m_nSegSize-m_nSegBufferPos, lSampleLen);
-				SampleBuffer.ReadBuffer (m_pSegBuffer+m_nSegBufferPos, nSize);
-				m_nSegBufferPos += nSize;
-			}
-			
-			if (m_nSegBufferPos >= m_nSegSize)
-			{
-				CGolombBuffer	SegmentBuffer (m_pSegBuffer, m_nSegSize);
+				HDMV_SEGMENT_TYPE	nSegType	= (HDMV_SEGMENT_TYPE)SampleBuffer.ReadByte();
+				USHORT				nUnitSize	= SampleBuffer.ReadShort();
+				lSampleLen -=3;
 
-				switch (m_nCurSegment)
+				switch (nSegType)
 				{
 				case PALETTE :
-					TRACE_HDMVSUB ("CHdmvSub:PALETTE            rtStart=%10I64d\n", rtStart);
-					ParsePalette(&SegmentBuffer, m_nSegSize);
-					break;
 				case OBJECT :
-					//TRACE_HDMVSUB ("CHdmvSub:OBJECT             %S\n", ReftimeToString(rtStart));
-					ParseObject(&SegmentBuffer, m_nSegSize);
+				case PRESENTATION_SEG :
+				case END_OF_DISPLAY :
+					m_nCurSegment = nSegType;
+					AllocSegment (nUnitSize);
 					break;
-				case PRESENTATION_SEG :
-					TRACE_HDMVSUB ("CHdmvSub:PRESENTATION_SEG   %S (size=%d)\n", ReftimeToString(rtStart), m_nSegSize);
-					
-					if (m_pCurrentObject)
-					{
-						m_pCurrentObject->m_rtStop = rtStart;
-						m_pObjects.AddTail (m_pCurrentObject);
-						TRACE_HDMVSUB ("CHdmvSub:HDMV : %S => %S\n", ReftimeToString (m_pCurrentObject->m_rtStart), ReftimeToString(rtStart));
-						m_pCurrentObject = NULL;
-					}
 
-					if (ParsePresentationSegment(&SegmentBuffer) > 0)
-					{
-						m_pCurrentObject->m_rtStart	= rtStart;
-						m_pCurrentObject->m_rtStop	= _I64_MAX;
-					}
-					break;
 				case WINDOW_DEF :
-					// TRACE_HDMVSUB ("CHdmvSub:WINDOW_DEF         %S\n", ReftimeToString(rtStart));
+				case INTERACTIVE_SEG :
+				case HDMV_SUB1 :
+				case HDMV_SUB2 :
+					// Ignored stuff...
+					SampleBuffer.SkipBytes(nUnitSize);
 					break;
-				case END_OF_DISPLAY :
-					// TRACE_HDMVSUB ("CHdmvSub:END_OF_DISPLAY     %S\n", ReftimeToString(rtStart));
-					break;
 				default :
-					TRACE_HDMVSUB ("CHdmvSub:UNKNOWN Seg %d     rtStart=0x%10dd\n", m_nCurSegment, rtStart);
+					return VFW_E_SAMPLE_REJECTED;
 				}
+			}
 
-				m_nCurSegment = NO_SEGMENT;
-				return hr;
+			if (m_nCurSegment != NO_SEGMENT)
+			{
+				if (m_nSegBufferPos < m_nSegSize)
+				{
+					int		nSize = min (m_nSegSize-m_nSegBufferPos, lSampleLen);
+					SampleBuffer.ReadBuffer (m_pSegBuffer+m_nSegBufferPos, nSize);
+					m_nSegBufferPos += nSize;
+				}
+				
+				if (m_nSegBufferPos >= m_nSegSize)
+				{
+					CGolombBuffer	SegmentBuffer (m_pSegBuffer, m_nSegSize);
+
+					switch (m_nCurSegment)
+					{
+					case PALETTE :
+						TRACE_HDMVSUB ("CHdmvSub:PALETTE            rtStart=%10I64d\n", rtStart);
+						ParsePalette(&SegmentBuffer, m_nSegSize);
+						break;
+					case OBJECT :
+						//TRACE_HDMVSUB ("CHdmvSub:OBJECT             %S\n", ReftimeToString(rtStart));
+						ParseObject(&SegmentBuffer, m_nSegSize);
+						break;
+					case PRESENTATION_SEG :
+						TRACE_HDMVSUB ("CHdmvSub:PRESENTATION_SEG   %S (size=%d)\n", ReftimeToString(rtStart), m_nSegSize);
+						
+						if (m_pCurrentObject)
+						{
+							m_pCurrentObject->m_rtStop = rtStart;
+							m_pObjects.AddTail (m_pCurrentObject);
+							TRACE_HDMVSUB ("CHdmvSub:HDMV : %S => %S\n", ReftimeToString (m_pCurrentObject->m_rtStart), ReftimeToString(rtStart));
+							m_pCurrentObject = NULL;
+						}
+
+						if (ParsePresentationSegment(&SegmentBuffer) > 0)
+						{
+							m_pCurrentObject->m_rtStart	= rtStart;
+							m_pCurrentObject->m_rtStop	= _I64_MAX;
+						}
+						break;
+					case WINDOW_DEF :
+						// TRACE_HDMVSUB ("CHdmvSub:WINDOW_DEF         %S\n", ReftimeToString(rtStart));
+						break;
+					case END_OF_DISPLAY :
+						// TRACE_HDMVSUB ("CHdmvSub:END_OF_DISPLAY     %S\n", ReftimeToString(rtStart));
+						break;
+					default :
+						TRACE_HDMVSUB ("CHdmvSub:UNKNOWN Seg %d     rtStart=0x%10dd\n", m_nCurSegment, rtStart);
+					}
+
+					m_nCurSegment = NO_SEGMENT;
+				}
 			}
 		}
 	}
Index: mpc-hc_subs/src/subtitles/SubtitleInputPin.cpp
===================================================================
--- mpc-hc_subs/src/subtitles/SubtitleInputPin.cpp	(revision 26069)
+++ mpc-hc_subs/src/subtitles/SubtitleInputPin.cpp	(working copy)
@@ -64,8 +64,7 @@
 		|| pmt->majortype == MEDIATYPE_Subtitle && (pmt->subtype == MEDIASUBTYPE_SSA || pmt->subtype == MEDIASUBTYPE_ASS || pmt->subtype == MEDIASUBTYPE_ASS2)
 		|| pmt->majortype == MEDIATYPE_Subtitle && pmt->subtype == MEDIASUBTYPE_SSF
 		|| pmt->majortype == MEDIATYPE_Subtitle && (pmt->subtype == MEDIASUBTYPE_VOBSUB)
-		|| pmt->majortype == MEDIATYPE_Subtitle && pmt->subtype == MEDIASUBTYPE_HDMVSUB
-		|| pmt->majortype == MEDIATYPE_Subtitle && pmt->subtype == MEDIASUBTYPE_DVB_SUBTITLES
+		|| IsHdmvSub(pmt)
 		? S_OK 
 		: E_FAIL;
 }
@@ -139,14 +138,10 @@
 			CVobSubStream* pVSS = (CVobSubStream*)(ISubStream*)m_pSubStream;
 			pVSS->Open(name, m_mt.pbFormat + dwOffset, m_mt.cbFormat - dwOffset);
 		}
-		else if (m_mt.subtype == MEDIASUBTYPE_HDMVSUB)
+		else if (IsHdmvSub(&m_mt))
 		{
-			if(!(m_pSubStream = DNew CRenderedHdmvSubtitle(m_pSubLock, ST_HDMV))) return E_FAIL;
+			if(!(m_pSubStream = DNew CRenderedHdmvSubtitle(m_pSubLock, (m_mt.subtype == MEDIASUBTYPE_DVB_SUBTITLES) ? ST_DVB : ST_HDMV))) return E_FAIL;
 		}
-		else if (m_mt.subtype == MEDIASUBTYPE_DVB_SUBTITLES)
-		{
-			if(!(m_pSubStream = DNew CRenderedHdmvSubtitle(m_pSubLock, ST_DVB))) return E_FAIL;
-		}
 	}
 
 	AddSubStream(m_pSubStream);
@@ -210,7 +205,7 @@
 		CVobSubStream* pVSS = (CVobSubStream*)(ISubStream*)m_pSubStream;
 		pVSS->RemoveAll();
 	}
-	else if (m_mt.majortype == MEDIATYPE_Subtitle && (m_mt.subtype == MEDIASUBTYPE_HDMVSUB || m_mt.subtype == MEDIASUBTYPE_DVB_SUBTITLES) )
+	else if (IsHdmvSub(&m_mt))
 	{
 		CAutoLock cAutoLock(m_pSubLock);
 		CRenderedHdmvSubtitle* pHdmvSubtitle = (CRenderedHdmvSubtitle*)(ISubStream*)m_pSubStream;
@@ -390,14 +385,8 @@
 			CVobSubStream* pVSS = (CVobSubStream*)(ISubStream*)m_pSubStream;
 			pVSS->Add(tStart, tStop, pData, len);
 		}
-		else if (m_mt.subtype == MEDIASUBTYPE_HDMVSUB || m_mt.subtype == MEDIASUBTYPE_DVB_SUBTITLES)
+		else if (IsHdmvSub(&m_mt))
 		{
-//CComPtr<IReferenceClock>	pClock;
-//m_pFilter->GetSyncSource(&pClock);
-//CComPtr<IMpeg2DemultiplexerTesting>	 iTest;
-//pClock->QueryInterface(__uuidof(IMpeg2DemultiplexerTesting), (void**)&iTest);
-//ULONG ul;
-//iTest->GetMpeg2StreamType(&ul);
 			CAutoLock cAutoLock(m_pSubLock);
 			CRenderedHdmvSubtitle* pHdmvSubtitle = (CRenderedHdmvSubtitle*)(ISubStream*)m_pSubStream;
 			pHdmvSubtitle->ParseSample (pSample);
@@ -417,3 +406,11 @@
 }
 
 
+bool CSubtitleInputPin::IsHdmvSub(const CMediaType* pmt)
+{
+	return pmt->majortype == MEDIATYPE_Subtitle && (pmt->subtype == MEDIASUBTYPE_HDMVSUB ||			// Blu ray presentation graphics
+													pmt->subtype == MEDIASUBTYPE_DVB_SUBTITLES ||	// DVB subtitles
+												   (pmt->subtype == MEDIASUBTYPE_NULL && pmt->formattype == FORMAT_SubtitleInfo)) // Workaround : support for Haali PGS
+		 ? true
+		 : false;
+}
\ No newline at end of file
Index: mpc-hc_subs/src/subtitles/SubtitleInputPin.h
===================================================================
--- mpc-hc_subs/src/subtitles/SubtitleInputPin.h	(revision 26069)
+++ mpc-hc_subs/src/subtitles/SubtitleInputPin.h	(working copy)
@@ -38,6 +38,7 @@
 	virtual void AddSubStream(ISubStream* pSubStream) = 0;
 	virtual void RemoveSubStream(ISubStream* pSubStream) = 0;
 	virtual void InvalidateSubtitle(REFERENCE_TIME rtStart, ISubStream* pSubStream) = 0;
+	bool		 IsHdmvSub(const CMediaType* pmt);
 
 public:
 	CSubtitleInputPin(CBaseFilter* pFilter, CCritSec* pLock, CCritSec* pSubLock, HRESULT* phr);
